Get EGroupware's ID for a just-sent email

classic Classic list List threaded Threaded
4 messages Options
Nathan Gray Nathan Gray
Reply | Threaded
Open this post in threaded view
|

Get EGroupware's ID for a just-sent email

Given code like the following:

$mailObject = new Mailer($this->profileID);
$mailObject->addHeader('Subject',...);
...
$mailObject->send();

What is the best way to get EGroupware's ID for this mail, such that I can pass it on to mail_ui::generateRowID()?

I've tried reading the headers like this:
$headers = $this->getHeaders($_folder, 0, 1, Horde_Imap_Client::SORT_DATE, false, array());
$message_ID = $headers['header'][0]['uid'];

where $_folder is the Sent folder, but that seems to be inconsistent, sometimes working and sometimes returning the ID for an email sent 10 minutes prior.

Thanks,
Nathan

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
eGroupWare-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/egroupware-developers
hnategh hnategh
Reply | Threaded
Open this post in threaded view
|

Re: Get EGroupware's ID for a just-sent email

Hello Nathan,

I think you need to get the "Message-ID" from the header you added, you can do that by:
$message_id = $this->getHeader('Message-ID').

Then you have all you need to generate EGroupware's ID for the mail consisting of profileID+folderName+message_id.

Regarding the second question ( the getHeaders), there are two things:

1- The start message should be set to 1 instead of 0

2- For the sort criteria you need to use string 'date' instead of Horde_Imap_Client::SORT_DATE

Something like this:
$headers = $this->getHeaders($_folder, 1, 1, 'date', false, array());


Best regards,
Hadi Nategh
Software Developer

EGroupware GmbH [www.egroupware.org]
Handelsregister HRB Kaiserslautern 3587
Geschäftsführer Birgit und Ralf Becker
Leibnizstr. 17, 67663 Kaiserslautern, Germany
Telefon +49 631 31657-0 e
hnategh hnategh
Reply | Threaded
Open this post in threaded view
|

Re: Get EGroupware's ID for a just-sent email

Hi Nathan,

Just a correction to my previous answer, my answer to your first question is wrong because the Message-ID is not the UID which  you actually need to get. In order to get the uid you need to save the message to send folder and then get the uid from the saved message. We already have a method for it in Mail class, it's called appendMessage() and returns uid.

Regards,
Hadi Nategh
Software Developer

EGroupware GmbH [www.egroupware.org]
Handelsregister HRB Kaiserslautern 3587
Geschäftsführer Birgit und Ralf Becker
Leibnizstr. 17, 67663 Kaiserslautern, Germany
Telefon +49 631 31657-0 e
Nathan Gray Nathan Gray
Reply | Threaded
Open this post in threaded view
|

Re: Get EGroupware's ID for a just-sent email



On 19 January 2017 at 08:52, hnategh <[hidden email]> wrote:
Hi Nathan,

Just a correction to my previous answer, my answer to your first question is
wrong because the Message-ID is not the UID which  you actually need to get.
In order to get the uid you need to save the message to send folder and then
get the uid from the saved message. We already have a method for it in Mail
class, it's called appendMessage() and returns uid.

That's what I needed, thanks. 

Nathan

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
eGroupWare-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/egroupware-developers