<?xml version="1.0"?>
<?xml-stylesheet 
 href="http://www.w3.org/2000/08/w3c-synd/style.css" type="text/css"
?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel rdf:about="http://pear.php.net/bugs/8723/bug">
    <title>PEAR Bug #8723</title>
    <link>http://pear.php.net/bugs/8723</link>
    <description>[Closed] Missing trailing newline in headers with SMTP backend</description>
    <dc:language>en-us</dc:language>
    <dc:creator>pear-webmaster@lists.php.net</dc:creator>
    <dc:publisher>pear-webmaster@lists.php.net</dc:publisher>
    <admin:generatorAgent rdf:resource="http://pear.php.net/bugs"/>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
    <items>
     <rdf:Seq>
      <rdf:li rdf:resource="http://pear.php.net/bugs/8723"/>
      <rdf:li rdf:resource="http://pear.php.net/bugs/8723/2006-10-11+16%3A34%3A06#2006-10-11+16%3A34%3A06"/>
      <rdf:li rdf:resource="http://pear.php.net/bugs/8723/2006-09-30+00%3A19%3A09#2006-09-30+00%3A19%3A09"/>
      <rdf:li rdf:resource="http://pear.php.net/bugs/8723/2006-09-26+09%3A10%3A57#2006-09-26+09%3A10%3A57"/>
     </rdf:Seq>
    </items>
  </channel>
    <item rdf:about="http://pear.php.net/bugs/8723">
      <title>roychri@... [2006-09-17 10:45:08]</title>
      <link>http://pear.php.net/bugs/8723</link>
      <description><![CDATA[<pre>Mail Bug
Reported by roychri@...
2006-09-17T14:45:08-00:00
PHP: 4.4.0 OS: Any Package Version: 1.1.13

Description:
------------
I recently upgraded Mail to version 1.1.13 and my scripts using Mail with the smtp backend started failing.
There is not enough newlines between the headers and the body anymore.
If I revert back to 1.1.10, I have no problems.

In the example I provided in this bug, I replaced actual email adresses by &quot;x&quot; to prevent spam.


I saw that the Mail/sendmail.php was changed (Revision 1.17) to provide two seperator ($this-&gt;sep) and I thought that the same would apply to Mail/smtp.php so I propose a patch (included in the text script section).  This patch works for me.



Test script:
---------------
require_once(&quot;Mail.php&quot;);
$recipients = 'x';
$params = Array('host' =&gt; 'localhost', 'port' =&gt; 25, 'debug' =&gt; true);
$mail_object =&amp; Mail::factory('smtp', $params);
$headers['From']    = 'x';
$headers['To']      = $recipients;
$headers['Subject'] = 'Test message';
header(&quot;Content-Type: text/plain&quot;);
$mail_object-&gt;send($recipients, $headers, $body = 'Test message');


========================================


--- Mail/smtp.php~	2006-09-17 10:12:18.000000000 -0400
+++ Mail/smtp.php	2006-09-17 10:16:29.000000000 -0400
@@ -288,7 +288,8 @@
         }
 
         /* Send the message's headers and the body as SMTP data. */
-        if (PEAR::isError($res = $this-&gt;_smtp-&gt;data(&quot;$textHeaders\r\n$body&quot;))) {
+        $data = $textHeaders.&quot;\r\n\r\n&quot;.$body;
+        if (PEAR::isError($res = $this-&gt;_smtp-&gt;data($data))) {
             $error = $this-&gt;_error('Failed to send data', $res);
             $this-&gt;_smtp-&gt;rset();
             return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_DATA);


Expected result:
----------------
DEBUG: Recv: 220 x ESMTP Sendmail 8.13.6/8.13.6; Sun, 17 Sep 2006 10:35:16 -0400
DEBUG: Send: EHLO localhost

DEBUG: Recv: 250-x Hello x [209.249.12.15], pleased to meet you
DEBUG: Send: MAIL FROM:&lt;x&gt;

DEBUG: Recv: 250 2.1.0 &lt;x&gt;... Sender ok
DEBUG: Send: RCPT TO:&lt;x&gt;

DEBUG: Recv: 250 2.1.5 &lt;x&gt;... Recipient ok
DEBUG: Send: DATA

DEBUG: Recv: 354 Enter mail, end with &quot;.&quot; on a line by itself
DEBUG: Send: From: x
To: x
Subject: Test message

Test message
.

DEBUG: Recv: 250 2.0.0 k8HEZGSO004852 Message accepted for delivery
DEBUG: Send: QUIT

DEBUG: Recv: 221 2.0.0 x closing connection


Actual result:
--------------
DEBUG: Recv: 220 x ESMTP Sendmail 8.13.6/8.13.6; Sun, 17 Sep 2006 10:32:47 -0400
DEBUG: Send: EHLO localhost

DEBUG: Recv: 250-x Hello x [209.249.12.15], pleased to meet you
DEBUG: Send: MAIL FROM:&lt;x&gt;

DEBUG: Recv: 250 2.1.0 &lt;x&gt;... Sender ok
DEBUG: Send: RCPT TO:&lt;x&gt;

DEBUG: Recv: 250 2.1.5 &lt;x&gt;... Recipient ok
DEBUG: Send: DATA

DEBUG: Recv: 354 Enter mail, end with &quot;.&quot; on a line by itself
DEBUG: Send: From: x
To: x
Subject: Test message
Test message
.

DEBUG: Recv: 250 2.0.0 k8HEWlqE003028 Message accepted for delivery
DEBUG: Send: QUIT

DEBUG: Recv: 221 2.0.0 x closing connection</pre>]]></description>
      <content:encoded><![CDATA[<pre>Mail Bug
Reported by roychri@...
2006-09-17T14:45:08-00:00
PHP: 4.4.0 OS: Any Package Version: 1.1.13

Description:
------------
I recently upgraded Mail to version 1.1.13 and my scripts using Mail with the smtp backend started failing.
There is not enough newlines between the headers and the body anymore.
If I revert back to 1.1.10, I have no problems.

In the example I provided in this bug, I replaced actual email adresses by &quot;x&quot; to prevent spam.


I saw that the Mail/sendmail.php was changed (Revision 1.17) to provide two seperator ($this-&gt;sep) and I thought that the same would apply to Mail/smtp.php so I propose a patch (included in the text script section).  This patch works for me.



Test script:
---------------
require_once(&quot;Mail.php&quot;);
$recipients = 'x';
$params = Array('host' =&gt; 'localhost', 'port' =&gt; 25, 'debug' =&gt; true);
$mail_object =&amp; Mail::factory('smtp', $params);
$headers['From']    = 'x';
$headers['To']      = $recipients;
$headers['Subject'] = 'Test message';
header(&quot;Content-Type: text/plain&quot;);
$mail_object-&gt;send($recipients, $headers, $body = 'Test message');


========================================


--- Mail/smtp.php~	2006-09-17 10:12:18.000000000 -0400
+++ Mail/smtp.php	2006-09-17 10:16:29.000000000 -0400
@@ -288,7 +288,8 @@
         }
 
         /* Send the message's headers and the body as SMTP data. */
-        if (PEAR::isError($res = $this-&gt;_smtp-&gt;data(&quot;$textHeaders\r\n$body&quot;))) {
+        $data = $textHeaders.&quot;\r\n\r\n&quot;.$body;
+        if (PEAR::isError($res = $this-&gt;_smtp-&gt;data($data))) {
             $error = $this-&gt;_error('Failed to send data', $res);
             $this-&gt;_smtp-&gt;rset();
             return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_DATA);


Expected result:
----------------
DEBUG: Recv: 220 x ESMTP Sendmail 8.13.6/8.13.6; Sun, 17 Sep 2006 10:35:16 -0400
DEBUG: Send: EHLO localhost

DEBUG: Recv: 250-x Hello x [209.249.12.15], pleased to meet you
DEBUG: Send: MAIL FROM:&lt;x&gt;

DEBUG: Recv: 250 2.1.0 &lt;x&gt;... Sender ok
DEBUG: Send: RCPT TO:&lt;x&gt;

DEBUG: Recv: 250 2.1.5 &lt;x&gt;... Recipient ok
DEBUG: Send: DATA

DEBUG: Recv: 354 Enter mail, end with &quot;.&quot; on a line by itself
DEBUG: Send: From: x
To: x
Subject: Test message

Test message
.

DEBUG: Recv: 250 2.0.0 k8HEZGSO004852 Message accepted for delivery
DEBUG: Send: QUIT

DEBUG: Recv: 221 2.0.0 x closing connection


Actual result:
--------------
DEBUG: Recv: 220 x ESMTP Sendmail 8.13.6/8.13.6; Sun, 17 Sep 2006 10:32:47 -0400
DEBUG: Send: EHLO localhost

DEBUG: Recv: 250-x Hello x [209.249.12.15], pleased to meet you
DEBUG: Send: MAIL FROM:&lt;x&gt;

DEBUG: Recv: 250 2.1.0 &lt;x&gt;... Sender ok
DEBUG: Send: RCPT TO:&lt;x&gt;

DEBUG: Recv: 250 2.1.5 &lt;x&gt;... Recipient ok
DEBUG: Send: DATA

DEBUG: Recv: 354 Enter mail, end with &quot;.&quot; on a line by itself
DEBUG: Send: From: x
To: x
Subject: Test message
Test message
.

DEBUG: Recv: 250 2.0.0 k8HEWlqE003028 Message accepted for delivery
DEBUG: Send: QUIT

DEBUG: Recv: 221 2.0.0 x closing connection</pre>]]></content:encoded>
      <dc:date>2006-09-17T14:45:08-00:00</dc:date>
    </item>
    <item rdf:about="http://pear.php.net/bugs/8723/2006-10-11+16%3A34%3A06#2006-10-11+16%3A34%3A06">
      <title>chagenbu@... [2006-10-11 20:34]</title>
      <link>http://pear.php.net/bugs/8723#1160598846</link>
      <description><![CDATA[<pre>Thank you for your bug report. This issue has been fixed
in the latest released version of the package, which you can download at
http://pear.php.net/get/Mail</pre>]]></description>
      <content:encoded><![CDATA[<pre>Thank you for your bug report. This issue has been fixed
in the latest released version of the package, which you can download at
http://pear.php.net/get/Mail</pre>]]></content:encoded>
      <dc:date>2006-10-11T20:34:06-00:00</dc:date>
    </item>
    <item rdf:about="http://pear.php.net/bugs/8723/2006-09-30+00%3A19%3A09#2006-09-30+00%3A19%3A09">
      <title>tabacco@... [2006-09-30 04:19]</title>
      <link>http://pear.php.net/bugs/8723#1159589949</link>
      <description><![CDATA[<pre>I can verify this one as well.  the proposed patch worked for me.</pre>]]></description>
      <content:encoded><![CDATA[<pre>I can verify this one as well.  the proposed patch worked for me.</pre>]]></content:encoded>
      <dc:date>2006-09-30T04:19:09-00:00</dc:date>
    </item>
    <item rdf:about="http://pear.php.net/bugs/8723/2006-09-26+09%3A10%3A57#2006-09-26+09%3A10%3A57">
      <title>jj@... [2006-09-26 13:10]</title>
      <link>http://pear.php.net/bugs/8723#1159276257</link>
      <description><![CDATA[<pre>I have the same problem with version 1.1.13. The suggested patch (inserting &quot;\r\n&quot; between header and body) works for me.</pre>]]></description>
      <content:encoded><![CDATA[<pre>I have the same problem with version 1.1.13. The suggested patch (inserting &quot;\r\n&quot; between header and body) works for me.</pre>]]></content:encoded>
      <dc:date>2006-09-26T13:10:57-00:00</dc:date>
    </item>
</rdf:RDF>