ZF-2624: Message-ID getter/setter


I'm evaluating moving Mantis issue tracker code ( from phpmailer to Zend::Mail.
When notification mails are sent from a mantis installation, the Message-ID is set in such a way that subsequent mails coming from the same issue are threaded properly by email readers.

Right now, I can not find (neither in 1.5PR) any method for setting and getting the value of the Message-ID header, so this is clearly a blocker, at least in my use case.


Please evaluate and categorize/assign as necessary.

Will, I guess your comment is not addressed to me?

No. I was addressing Nico, who is the lead for the Zend_Mail component. Would you like to fix this one yourself?

The attached patch provides the required functions.

I am not sure if the setMessageId() method needs the same "sanitization" as you do in other header setters like setSubject(); that would be trivial to add though

Will, Nico, are there any chances this could be reviewed/pushed to SVN in time for 1.6 gold?

Ok, now that 1.6 is released, are you able to assign a target version to this?

Hadn't much time lately, but my current target for most mail issues is 1.7.

One question about this. You say you want the mails to be in the correct thread. Wouldn't it be more correct to add a message-id to the references header? I don't know how you decide to which thread a message belongs, but it seems like you'd sending several messages with the same message-id, which is not correct.

Yes, re-reading the description I realize the wording was not really clear.

Basically, the first mail we send on bug creation has a Message-ID composed from some unique data about the bug (ID, creation timestamp, etc).

When notes are added or other events trigger a mail to be sent, we are able to set a "In-Reply-To" header with the original Message-ID, and threading works as expected.

Anything more I can do here?


I think following is better.

1) At first , user calls enableMessageId() function that enables creating id before sending message. for example,

public function enableMessageId($flag) { $this->_useMessageId = (boolean) $flag; }

2)At second, user calls send method without calling creating id method.

send() method has creating message id logic,

if ($this->_useMessageId === true) { //Here is logic that creates message id. }

3) Thus, each time own id will be created without forgetting change value.

We can support both. Make it {{public function setMessageId($id = true)}} If $id is null or false no message-id header is added, if it's true a new id is generated, else the given one is taken. I didn't had the time to really look into the format for message-ids, but we already have to generate unique ids for writing to maildir. If we could reuse the functionality (making it a static method in Zend_Mail), that would be great.

Nico, I guess you did not notice my patch?

Hi, Gianluca Sforna . I will try to update this issue in next holiday ;-)

Hi Satoru (I guess that's your first name... mine is Gianluca); nice to see some activity here!

I just hope the next holiday where you live is not next Christmas ;)

Feel free to let me know if/how my patch should be revised and I can provide you an updated one.

Solved in SVN r13555

I added 4 methods.

setMessageId, getMessageId, clearMessageId, createMessageId.

Hi, Gianluca Thank you for your kindness, but never mind. I am not in the Orthodox church, a Buddhist :-)

I will be happy if you try new functions!

Additional Fix in SVN r13643.

Message-Id should be error on addHeader() function.