"/usr/sbin/sendmail" not working with SwiftMailer
Posted: Wed Feb 14, 2007 8:40 am
Hi,
I using SwiftMailer 2.1.7 PHP4.
My host are blocking SMTP connections and php mail() is not a good solution.
I try to send email by sendmail (/usr/sbin/sendmail), but it doesnt work.
SCRIPT:
LOG:
SCRIPT:
I prefer SwiftMailer, so anyone can help me??
Sorry my bad, bad, bad, English.
Thanks.
I using SwiftMailer 2.1.7 PHP4.
My host are blocking SMTP connections and php mail() is not a good solution.
I try to send email by sendmail (/usr/sbin/sendmail), but it doesnt work.
SCRIPT:
Code: Select all
<?php
require('./Swift/Swift.php');
require('./Swift/Connection/Sendmail.php');
$connection = new Swift_Connection_Sendmail(SWIFT_AUTO_DETECT);
$mailer = new Swift($connection);
//If anything goes wrong you can see what happened in the logs
if ($mailer->isConnected())
{
//Sends a simple email
$mailer->send(
'"RASP" <tt@tt.es>',
'"Newsletter" <tt@tt.es>',
'Some Subject',
"Hello Joe it's only me!"
);
//Closes cleanly... works without this but it's not as polite.
$mailer->close();
}
echo "The mailer failed to connect. Errors: <pre>".print_r($mailer->errors, 1)."</pre><br />
Log: <pre>".print_r($mailer->transactions, 1)."</pre>";
?>I try the PHPMailer in sendmail mode, and it send emails without errors.The mailer failed to connect. Errors:
Array
(
[0] => Array
(
[num] => -1
[time] => 0.06903200 1171463068
[message] => Send Error: Sending to 1 recipients rejected (bad response code).
)
)
LOG
Array
(
[0] => Array
(
[command] =>
[time] => 0.03933100 1171463068
[response] => 220 cgi00-ch.uk.clara.net ESMTP Exim 4.52 Wed, 14 Feb 2007 14:24:28 +0000
)
[1] => Array
(
[command] => EHLO http://www.movilquick.net
[time] => 0.05049900 1171463068
[response] => 250-cgi00-ch.uk.clara.net Hello web57990 at http://www.movilquick.net
250-SIZE 52428800
250-PIPELINING
250 HELP
)
[2] => Array
(
[command] => MAIL FROM:
[time] => 0.05136600 1171463068
[response] => 250 OK
)
[3] => Array
(
[command] => RCPT TO:
[time] => 0.05148800 1171463068
[response] => 550 Administrative prohibition
)
[4] => Array
(
[command] => RSET
[time] => 0.06893100 1171463068
[response] => 250 Reset OK
)
[5] => Array
(
[command] => QUIT
[time] => 0.06914100 1171463068
[response] => 221 cgi00-ch.uk.clara.net closing connection
)
)
SCRIPT:
Code: Select all
function SendmailSend($header, $body) {
if ($this->Sender != "")
$sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, $this->Sender);
else
$sendmail = sprintf("%s -oi -t", $this->Sendmail);
if(!@$mail = popen($sendmail, "w"))
{
$this->SetError($this->Lang("execute") . $this->Sendmail);
return false;
}
fputs($mail, $header);
fputs($mail, $body);
$result = pclose($mail) >> 8 & 0xFF;
if($result != 0)
{
$this->SetError($this->Lang("execute") . $this->Sendmail);
return false;
}
return true;
}Sorry my bad, bad, bad, English.
Thanks.