Zend Framework

Message-ID getter/setter

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0.3, 1.7.2
  • Fix Version/s: 1.7.3
  • Component/s: Zend_Mail
  • Labels:
    None
  • Fix Version Priority:
    Nice to Have

Description

I'm evaluating moving Mantis issue tracker code (http://www.mantisbt.org) 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.

Activity

Hide
Wil Sinclair added a comment -

Please evaluate and categorize/assign as necessary.

Show
Wil Sinclair added a comment - Please evaluate and categorize/assign as necessary.
Hide
Gianluca Sforna added a comment -

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

Show
Gianluca Sforna added a comment - Will, I guess your comment is not addressed to me?
Hide
Wil Sinclair added a comment -

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

Show
Wil Sinclair added a comment - No. I was addressing Nico, who is the lead for the Zend_Mail component. Would you like to fix this one yourself?
Hide
Gianluca Sforna added a comment -

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

Show
Gianluca Sforna added a comment - 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
Hide
Gianluca Sforna added a comment -

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

Show
Gianluca Sforna added a comment - Will, Nico, are there any chances this could be reviewed/pushed to SVN in time for 1.6 gold?
Hide
Gianluca Sforna added a comment -

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

Show
Gianluca Sforna added a comment - Ok, now that 1.6 is released, are you able to assign a target version to this?
Hide
Nico Edtinger added a comment -

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.

Show
Nico Edtinger added a comment - 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.
Hide
Gianluca Sforna added a comment -

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.

Show
Gianluca Sforna added a comment - 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.
Hide
Gianluca Sforna added a comment -

Anything more I can do here?

Show
Gianluca Sforna added a comment - Anything more I can do here?
Hide
Gianluca Sforna added a comment -

ping...

Show
Gianluca Sforna added a comment - ping...
Hide
Satoru Yoshida added a comment -

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.

Show
Satoru Yoshida added a comment - 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.
Hide
Nico Edtinger added a comment -

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.

Show
Nico Edtinger added a comment - 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.
Hide
Gianluca Sforna added a comment -

Nico, I guess you did not notice my patch?

Show
Gianluca Sforna added a comment - Nico, I guess you did not notice my patch?
Hide
Satoru Yoshida added a comment -

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

Show
Satoru Yoshida added a comment - Hi, Gianluca Sforna . I will try to update this issue in next holiday
Hide
Gianluca Sforna added a comment -

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.

Show
Gianluca Sforna added a comment - 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.
Hide
Satoru Yoshida added a comment -

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!

Show
Satoru Yoshida added a comment - 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!
Hide
Satoru Yoshida added a comment -

Additional Fix in SVN r13643.

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

Show
Satoru Yoshida added a comment - Additional Fix in SVN r13643. Message-Id should be error on addHeader() function.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
Not Specified
Original Estimate - Not Specified
Remaining:
0m
Remaining Estimate - 0 minutes
Logged:
3h 30m
Time Spent - 3 hours, 30 minutes