Postfix - improper command pipelining after HELO

I'm using Postfix v2.9.5 and just noticed this in the maillog.

Code:
Mar  4 17:55:37 localhost postfix/smtpd[13928]: connect from localhost[127.0.0.1]
Mar  4 17:55:37 localhost postfix/smtpd[13928]: improper command pipelining after HELO from localhost[127.0.0.1]: MAIL FROM: <support@example.com>\r\nRCPT TO: <****@gmail.com>\r\nDATA\r\nTo: ****@gmail.com
Mar  4 17:55:37 localhost postfix/smtpd[13928]: 7F0B345018: client=localhost[127.0.0.1]
Mar  4 17:55:37 localhost postfix/smtpd[13928]: lost connection after QUIT from localhost[127.0.0.1]
Mar  4 17:55:37 localhost postfix/smtpd[13928]: disconnect from localhost[127.0.0.1]

What is triggering this is a php mail script I'm using to keep clients updated.

Code:
$smtpServer = "localhost";
$localhost = "127.0.0.1";
$port = "25";
$timeout = "45";
$newLine = "\r\n";
$from = "support@example.com";

$smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout);
fputs($smtpConnect, "HELO $localhost". $newLine);
fputs($smtpConnect, "MAIL FROM: <$from>" . $newLine);
fputs($smtpConnect, "RCPT TO: <$Email>" . $newLine);
fputs($smtpConnect, "DATA" . $newLine);

$subj  = "Weekly Newsletter";
$mesg .= "Here is what's been happening this past week :\n\n";
$mesg .= "Then my newsletter info goes here ...\n\n";

$headers = "MIME-Version: 1.0" . $newLine;
$headers .= "Content-type: text/plain; charset=iso-8859-1" . $newLine;

fputs($smtpConnect, "To: $Email\r\nFrom: $from\r\nSubject: $subj\r\n$headers\r\n\r\n$mesg\r\n.\r\n");
fputs($smtpConnect,"QUIT" . $newLine);

fclose($smtpConnect);

I'm not sure if it's a problem with my php script - or a postfix setting.

Any ideas?
 
You aren't waiting for the server responses. You aren't even checking the server responses. Use a mail library, don't write your own.
 
Is there any special reason that you don't use mail/php5-imap?
Code:
$user = "me";
$pass = "nicepass";

$mbox = imap_open('{127.0.0.1:143/imap}', $user, $pass);
$to = $_POST["to"];
$subject = $_POST["subject"];
$cc = $_POST["cc"];
$bcc = $_POST["bcc"];
$body = $_POST["message"];

if ( imap_mail($to, $subject, $body,'' , $cc, $bcc) )
	echo "Your message was sent";
else
	echo "There was a problem while sending message";

imap_close($mbox);

This requires an IMAP server but you can use this.
 
Is there any special reason that you don't use mail/php5-imap?

I don't know the quality of the imap_mail() function as such, I do know that:

- imap_mail() sends mail with SMTP, an IMAP library is a strange place for it to live
- The PHP imap library isn't particularly good in general
- This seems like an `afterthought function', not a core part of the library
- The PHP standard library is not exactly known for `getting it right'

In other words: one might question the quality of the imap_mail() function ...

This requires an IMAP server but you can use this.
Note there are also many problems associated with the standard PHP mail() function, an obvious defect is that it's insecure unless you know what you're doing.
I would not recommend using it.

In any case, not rolling your own SMTP library is the best answer.
Swift Mailer is an excellent SMTP library.
 
Mayhem30 said:
Code:
...
fputs($smtpConnect, "HELO $localhost". $newLine);
...

For postfix allowing pipelining, you need to initiate the session using EHLO.
Code:
...
fputs($smtpConnect, "EHLO $localhost". $newLine);
...
In addition, you also need to check that the directive reject_unauth_pipelining is not active for the local connection.

Anyway, at one point in time, your code should read the response of postfix and act accordingly.
 
Carpetsmoker said:
The last update to PHPMailer is from 2009. Swift mailer is still being updated (last update: January 2013). Based on this alone, I would choose Swift mailer.

The version I have is: Version 5.2.4 (February 19, 2013)
 
Mayhem30 said:
The version I have is : Version 5.2.4 (February 19, 2013)

Ah, In my stupidity I clicked the `download' link on the PHPMailer site, this only has outdated downloads, the newer downloads are available at Google code :-/
In that case, use whatever you prefer.
 
Back
Top