This script runs perfectly until i add the:
Code: Select all
if($swift->send($message, $ml_email, $from_email)) echo "Sent";
else echo "Failed";Fatal error: Uncaught exception 'Swift_ConnectionException' with message 'There was a problem reading line 1 of an SMTP response. The response so far was:
[]. It appears the connection has died without saying goodbye to us! Too many emails in one go perhaps? (fsockopen: #0) ' in /home/dstefani/public_html/swift_lib/Swift/Connection/SMTP.php:250 Stack trace: #0 /home/dstefani/public_html/swift_lib/Swift.php(306): Swift_Connection_SMTP->read() #1 /home/dstefani/public_html/swift_lib/Swift.php(386): Swift->command('RCPT TO: send(Object(Swift_Message), 'noname@noname.c...', 'don@server.com') #3 {main} thrown in /home/don/public_html/swift_lib/Swift/Connection/SMTP.php on line 250
Code: Select all
<?php
$dblink = db_connect();
//Load in the files we'll need
require_once "swift_lib/Swift.php";
require_once "swift_lib/Swift/Connection/SMTP.php";
$swift = new Swift(new Swift_Connection_SMTP("mail.server.com"));
$from_email = 'don@server.com';
$mail_success = 0;
$mail_failure = 0;
$mail_count = 0;
$failure_list = array();
$today = date("Y-m-d");
$sql = "SELECT nl_subject, nl_text FROM newsletter_tool WHERE nl_id = 1";
if(!$results = mysql_query($sql, $dblink)) die( mysql_error() . "<p>Newsletter: $sql</p>");
$nl = mysql_fetch_object($results);
$mail_subject = $nl->nl_subject;
$mail_body = $nl->nl_text;
$message = new Swift_Message($mail_subject, $mail_body);
$message->setReturnPath($from_mail);
$email_array = array();
$email_array[] = 'email_one@gmail.com';
$email_array[] = 'email_two@gmail.com';
$email_array[] = 'email_three@server.com';
$email_array[] = 'noname@noname.com';
$email_array[] = 'somename@somename.com';
foreach($email_array AS $ml_email) {
print "$ml_email<br />\n";
if($swift->send($message, $ml_email, $from_email)) echo "Sent";
else echo "Failed";
}
?>- Don