スクリプトからメールを送信するためにPEARのメールパッケージを使用しています。すべてが正しく接続され、宣言されていることは間違いありませんが、スクリプトを実行すると、実際に電子メールを送信せずに、接続してすぐにメールサーバーに切断します。
私のPostfixログから:
Nov 18 16:15:49 mailer postfix/smtpd[30346]: connect from xxx-xxx-xxx-xxx.static.cloud-ips.com[xxx.xxx.xxx.xxx]
Nov 18 16:15:49 mailer postfix/smtpd[30346]: disconnect from xxx-xxx-xxx-xxx.static.cloud-ips.com[xxx.xxx.xxx.xxx]
何が得られますか?
<?php
require_once('Mail.php'); // loads in PEAR Mail package
$mailer_params['host'] = 'mailer.example.com';
$mailer_params['port'] = 25;
$mailer_params['auth'] = true;
$mailer_params['username'] = 'user@mailer.example.com';
$mailer_params['password'] = 'password';
$mail =& Mail::factory('smtp', $mailer_params);
$headers = array(
'From' => 'user@example.com',
'Reply-To' => 'user@example.com',
'Subject' => 'Test Email'
);
$message = "whatever";
$mail->send('Test <other.user@example.com>', $headers, $message);
?>
Postfixサーバーを問題なく使用している他のアプリケーションがいくつかあるので、Postfixサーバーが機能することはわかっています。このスクリプトでは、ユーザーの資格情報は他のアプリの場合と同じです。
私のPostfixサーバーはSASL_auth(CRAM-MD5で構成されている)を使用しています。PHP側またはPostfix側のいずれかにエラーメッセージなどが表示されたらいいのですが、接続してから切断するだけで、他の説明はありません。