PHP forum

How to retrieve message_id from sent emails?

Feb 26, 2010 12:04 pm
Tony Marston

I am using the IMAP extension to transfer incoming emails from my inbox to a
database table in the CRM application which I am developing. I shall have
screens to view the emails, usually related to a particular customer. I
shall also have screens where outgoing emails can be composed before they
are sent out.

When I receive a reply to an email I can use the in_reply_to field to relate
it back to the message_id of the original email, but this is only useful if
I know the message_id of that email. The value for message_id is not
available until AFTER the message has been sent out, so how do I capture the
message_id of the email which I have just sent?

Feb 26, 2010 2:57 pm
Tyrone Slothrop
Re: How to retrieve message_id from sent emails?

On Fri, 26 Feb 2010 12:04:56 -0000, "Tony Marston"
<tony@NOSPAM.demon.co.uk> wrote:

>I am using the IMAP extension to transfer incoming emails from my inbox to a
>database table in the CRM application which I am developing. I shall have
>screens to view the emails, usually related to a particular customer. I
>shall also have screens where outgoing emails can be composed before they
>are sent out.
>
>When I receive a reply to an email I can use the in_reply_to field to relate
>it back to the message_id of the original email, but this is only useful if
>I know the message_id of that email. The value for message_id is not
>available until AFTER the message has been sent out, so how do I capture the
>message_id of the email which I have just sent?

You may define the Message-Id: within the headers:
$headers .= "Message-Id: some_value@yourdomain.com\n";

I generally use a string like:
time()."_uniqueid@domain";

You can use headers to perform lots of tasks for you but you can
seldom control what is returned in a response.

The purpose I have in setting the Message-Id is to identify users in
the event a bounce which is parsed by a script piped from a
Return-Path address.


Feb 26, 2010 7:05 pm
Peter H. Coffin
Re: How to retrieve message_id from sent emails?

On Fri, 26 Feb 2010 12:04:56 -0000, Tony Marston wrote:
> I am using the IMAP extension to transfer incoming emails from my inbox to a
> database table in the CRM application which I am developing. I shall have
> screens to view the emails, usually related to a particular customer. I
> shall also have screens where outgoing emails can be composed before they
> are sent out.
>
> When I receive a reply to an email I can use the in_reply_to field to relate
> it back to the message_id of the original email, but this is only useful if
> I know the message_id of that email. The value for message_id is not
> available until AFTER the message has been sent out, so how do I capture the
> message_id of the email which I have just sent?

Mail servers generate message IDs for messages that don't have one. If
the mail already has one, a new one won't be generated. (Note: properly,
you'll want to ensure that the message ID is forever unique. FQDN and
microtime() will probably do nicely.)

Whenever you look at a beautiful woman,
always remember that somewhere, someone is tired of her.
Feb 27, 2010 6:56 am
Tony Marston
Re: How to retrieve message_id from sent emails?

Thanks. That's useful to know.

Tony Marston
http://www.tonymarston.net
http://www.radicore.org
"Tyrone Slothrop" <ts@paranoids.org> wrote in message
news:njnfo5t08pe89abahq296b25q1vn099lrf@4ax.com...
> On Fri, 26 Feb 2010 12:04:56 -0000, "Tony Marston"
> <tony@NOSPAM.demon.co.uk> wrote:
>
>>I am using the IMAP extension to transfer incoming emails from my inbox to
>>a
>>database table in the CRM application which I am developing. I shall have
>>screens to view the emails, usually related to a particular customer. I
>>shall also have screens where outgoing emails can be composed before they
>>are sent out.
>>
>>When I receive a reply to an email I can use the in_reply_to field to
>>relate
>>it back to the message_id of the original email, but this is only useful
>>if
>>I know the message_id of that email. The value for message_id is not
>>available until AFTER the message has been sent out, so how do I capture
>>the
>>message_id of the email which I have just sent?
>
> You may define the Message-Id: within the headers:
> $headers .= "Message-Id: some_value@yourdomain.com\n";
>
> I generally use a string like:
> time()."_uniqueid@domain";
>
> You can use headers to perform lots of tasks for you but you can
> seldom control what is returned in a response.
>
> The purpose I have in setting the Message-Id is to identify users in
> the event a bounce which is parsed by a script piped from a
> Return-Path address.


Previous Thread: What makes programming effective?
Next Thread: Email attachment

Related Forum Topics
How to retrieve xml data from three tables of mysql
hay gays i want to retrieve xml data from three table stored in mysql.
i used the below code it works fine but first it retrieve one record
from first table than iterate to second table and print the whole
table and then iterate to third table and print the whole table but i
want to print...
Help with script that retrieve remote files
Hello,

I know very little about programming, even so I was able to use PHP
Simple DOM for open a file and outputs a new xml file. I'm trying to
create a WordPress xml import script for a specific local service that
doesn't offer any content export. The script must open all remote
files...
Retrieve all HTML elements, their attributes, attribute values, and text from a string?
I was wondering if anyone out there had a function/ class available
they would be willing to share which could retrieve all HTML elements
from a string and for each element, retrieve all attributes, all
attribute values, and whatever text is contained within that element?

TIA


Only 1 of 2 emails recived
When I use the following code if I send 2 consecutive emails to the
same address only the first one is received. If I put in a sleep(5)
both are received.
Thanks,
Shmuel
----------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
Cannot send emails
Hi,

I have problems sending mails. The messages are as follows:

PHP Warning: Connection refused in /usr/share/php/PEAR.php on line 873
PHP Warning: Failed to connect socket: Connection refused in /usr/share/php/PEAR.php on line 873

I used the following code:

<?php
require_once...
I do not receive emails sent by PHPMailer
Hello,
I am learning PHP5. I wrote the function sending email. I used
PHPMailer:

function sendEmail($to, $recipients, $subject, $bodyText, $bodyHTML,
$fullAnnouncementNo, $withAttachments, $logEntry) {

global $db, $websiteRoot;

try {

$mail = new PHPMailer();

...
Mail function, where emails are written ?
I wrote a very simple email script and deployed it on 2 computers
(Vista and XP) with apache and php installed (AppServ distribution).

These pc are connected to my home wireless router and the mail server
to which I'm connecting to is the provider one.

I have NO script errors on both PC...
Embedding a Link in Posts, Emails and Documents
Hello all,

I have just written my first web site and I have a link that goes to a
particular item with a parameter as in www.domain.com/?a=L123AB I want
people to be able to put the link wherever they want to give others
one-click access to that item on my site. I can think of 3...
Error message with if statement huh?
if (a == 1) {b == 2};

Error message says unexpected "}".

Why?



What is this error message telling me?
for ($i=0; $i<=3; $++) {
print("<img src='$pic[$i]' width='100' height='100'>");
}

This code produces the following error:

Parse error:syntax error, unexpected T_INC, expecting T_VARIABLE or '$'

So what am I missing?