log not working
Posted: Sun Aug 26, 2007 3:26 pm
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
Code: Select all
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();