Discussion:
Apparent error in Zend_Mail: duplicated newline in header
Cameron Laird
2007-08-29 19:58:17 UTC
Permalink
I can exhibit a minimal Zend e-mail script which appears to me to
put bad DATA on the wire. Is this the mailing list where I should
best report my observation?

Consider this:

<?php
require_once
'/usr/local/Zend/ZendFramework/library/Zend/Mail/Transport/Smtp.php';
require_once '/usr/local/Zend/ZendFramework/library/Zend/Mail.php';


$tr = new Zend_Mail_Transport_Smtp($server_host);
Zend_Mail::setDefaultTransport($tr);
$mail = new Zend_Mail();
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom('cameron-/awGbKECNgO/3pe1ocb+swC/***@public.gmane.org', 'Cameron Laird');
$mail->addTo($to, 'Cameron Laird');
$mail->setSubject('This is a subject line.');
$mail->send();

echo "Success!\n";
?>

I've experimented with four MTAs so far. I get consistent results:
the DATA coming out look like
Subject: This is a subject line.
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
This is the text of the mail.
.
(use any conventient packet sniffer). As RFC 822 teaches us, this
can only mean that the "To:", "Subject:", and other header elements
are to be interpreted as part of the body; that's what the duplicated
newline after "From:" accomplishes. Now what?

I'd like to report the release number of the Zend (Core? Framework?
...) I'm using. I don't understand its naming scheme, though; perhaps
one of you can help me with that, too.

Do others see this symptom? Has it been corrected already? Do I
need to patch PHP to work around this?
Matthew Weier O'Phinney
2007-09-11 20:37:57 UTC
Permalink
Post by Cameron Laird
I can exhibit a minimal Zend e-mail script which appears to me to
put bad DATA on the wire. Is this the mailing list where I should
best report my observation?
<?php
require_once
'/usr/local/Zend/ZendFramework/library/Zend/Mail/Transport/Smtp.php';
require_once '/usr/local/Zend/ZendFramework/library/Zend/Mail.php';
$tr = new Zend_Mail_Transport_Smtp($server_host);
Zend_Mail::setDefaultTransport($tr);
$mail = new Zend_Mail();
$mail->setBodyText('This is the text of the mail.');
$mail->addTo($to, 'Cameron Laird');
$mail->setSubject('This is a subject line.');
$mail->send();
echo "Success!\n";
?>
the DATA coming out look like
Subject: This is a subject line.
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
This is the text of the mail.
.
(use any conventient packet sniffer). As RFC 822 teaches us, this
can only mean that the "To:", "Subject:", and other header elements
are to be interpreted as part of the body; that's what the duplicated
newline after "From:" accomplishes. Now what?
I'd like to report the release number of the Zend (Core? Framework?
...) I'm using. I don't understand its naming scheme, though; perhaps
one of you can help me with that, too.
Do others see this symptom? Has it been corrected already? Do I
need to patch PHP to work around this?
Sorry I haven't looked into this sooner; I've been working on other
projects during the past week.

I've looked into this on Postfix, Exchange, and qmail. Exchange was the
only one where I saw this behaviour -- and, in fact, on that server
there were extra lines between *all* mail headers.

I did some experimentation by overriding the class and, specifically,
overriding the $EOL property to be "\n" instead of "\r\n". When done in
this fashion, Exchange exhibited no issues. I then tried it with each of
Postfix and qmail, and, surprisingly, all worked fine. I've committed
this as revision 6298 in trunk (file
library/Zend/Mail/Transport/Smtp.php); please test and verify. If this
solves your issue, I'll commit it to the release branch as well.

I can't say I like the solution, as it goes against the RFCs, but if it
works, that's the critical criterion.
--
Matthew Weier O'Phinney
PHP Developer | matthew-C1q0ot2/***@public.gmane.org
Zend - The PHP Company | http://www.zend.com/
Loading...