I am using pear to send email using the code below, on the first time through I get this error every time:
"Failed to set sender: aa@bb.com [SMTP: Invalid response code received from server (code: -1, response: )]"
If I debug and set the execution point back to 'Re-run from here' after the send, it works fine - almost like something is not initialised properly first time round - anyone have any ideas on this?
require_once "Mail.php";
function SendEMail() {
$from = "Sender Sender <sender@example.com>";
$to = "AA BB <aa@bb.com>";
$subject = "Test";
$body = "This is a test";
$host = "myhost";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
//Re-run from here
$smtp =& Mail::factory('smtp',
array ('host' => $host,
'auth' => false,
'username' => '',
'password' => ''));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
$s = $mail->getMessage();
}
}