I'm trying to print out the failed recipients log (hopefully, I'll be able to add them into mysql later!). I've followed the examples, but for some reason the log isn't working for me. Usually is a non object error that's thrown. 3.3.1 PHP 4
require_once "includes/mail/swift/Swift.php";
require_once "includes/mail/swift/Swift/Connection/Sendmail.php";
$log =& Swift_LogContainer::getLog();
$log->setLogLevel(SWIFT_LOG_EVERYTHING);
//Try to connect using /usr/sbin/sendmail -bs
$swift =& new Swift(new Swift_Connection_Sendmail());
// OR
//Let the connection try to work out the path itself (PHP4)
//$swift =& new Swift(new Swift_Connection_Sendmail(SWIFT_SENDMAIL_AUTO_DETECT));
// build the HTML part of the message
$html_message = file_get_contents('../data/cache/files/cache_html.php');
// build the text part of the message
$text_message = '';
if($row_prefs['use_nospam_head'] == 1) {
$text_message .= "\n".$row_prefs['nospam_head']."\n";
}
$text_message .= file_get_contents('../data/cache/files/cache_text.php');
if($row_prefs['use_nospam_foot'] == 1) {
$text_message .= "\n".$row_prefs['nospam_foot']."\n";
}
$text_message .= POWERED_BY_TXT;
$message =& new Swift_Message($subject);
//Add the "parts"
$message->attach(new Swift_Message_Part($text_message));
$message->attach(new Swift_Message_Part($html_message, "text/html"));
if(VERSION == 1 && $row_prefs['sent_status'] == 1) {
// if we want confirmation that the recipient read the email
mysql_select_db($database, $conn) or die(mysql_error());
$sql = mysql_query("SELECT email_contact FROM {$database}.admin WHERE username = '{$_SESSION['username']}'") or die(sql_error('could not retrieve admin contact email address: functions/email.php'));
$row_admin = mysql_fetch_array($sql);
$message->requestReadReceipt($from_address);
}
// build the recipients list
$recipients =& new Swift_RecipientList();
$recipients->addTo($to);
// bounce address
$message->setReturnPath(new Swift_Address($reply_address));
//And send like usual
if ($swift->batchSend($message, $recipients, new Swift_Address($reply_address, $row_prefs['eName']))) {
$sent = true;
}
echo "<pre>" . htmlentities($swift->log->dump(true)) . "</pre>";
$swift->disconnect();
Basically I changed the log so it's no longer nested inside the Swift instance because it was impossible to debug errors when something goes wrong in the constructor of Swift.
EDIT | Hmm, looks I already updated this anyway, and you're using the new code, except you've left a call to $swift->log where it should just be $log
Shouldn't Swiftmailer have sent that back to me as a hard bounce?
Did batchSend() return true? If your mail server accepts the email there's nothing Swift can do. It can't detect "bounces", it can only detect failures at SMTP-time
d11wtq wrote:Did batchSend() return true? If your mail server accepts the email there's nothing Swift can do. It can't detect "bounces", it can only detect failures at SMTP-time
Yep. It returned true.
I would think that an email like that would be returned at SMTP-time?
d11wtq wrote:Did batchSend() return true? If your mail server accepts the email there's nothing Swift can do. It can't detect "bounces", it can only detect failures at SMTP-time
Yep. It returned true.
I would think that an email like that would be returned at SMTP-time?
It depends on the configuration of the server. Your server is not rejecting it, it's just going to wait and see if it bounces later (it'll be spooled first). Most servers have an option to enable host lookups, but it looks like your has this turned off. Nothing to do with Swift either way
d11wtq wrote:Did batchSend() return true? If your mail server accepts the email there's nothing Swift can do. It can't detect "bounces", it can only detect failures at SMTP-time
Yep. It returned true.
I would think that an email like that would be returned at SMTP-time?
It depends on the configuration of the server. Your server is not rejecting it, it's just going to wait and see if it bounces later (it'll be spooled first). Most servers have an option to enable host lookups, but it looks like your has this turned off. Nothing to do with Swift either way
Regardless, thanks for your help and thanks for creating a terrific library. As I was working on this yesterday, I was switching my system over from phpmailer. No regrets