So I just sent 5 emails with the following code:
Code: Select all
//Create the Transport
//$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
$transport = Swift_SmtpTransport::newInstance('smpt.server.tld', 25);
//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
//Use AntiFlood to re-connect after 100 emails
$mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100));
// get database info.
$sql = "SELECT p.`firstName`, p.`lastName`, e.`email`, e.`emailCode` FROM `Emails` e LEFT JOIN `Persons` p ON e.`PersonID` = p.`PersonID` ORDER BY e.`email` ASC";
//$sql = "SELECT `email`, `emailCode` FROM `Emails`";// WHERE `email` LIKE 'brett%'";
//$rows = $data->get_rows($sql);
$rows = array(
array('Brett', 'Obfuscated', 'obfuscated@gmail.com', 'gmail'),
array('Brett', 'Obfuscated', 'obfuscated@obfuscated.com', 'obfuscated'),
array('Brett', 'Obfuscated', 'obfuscated@yahoo.com', 'yahoo'),
array('Brett', 'Obfuscatedt', 'obfuscated@hotmail.com', 'msn'),
array('Brett', 'Obfuscated', 'obfuscated@obfuscated.org', 'bretticus'),
);
//Build replacement array for decorator plugin and address batch send to all users.
$replacements = array();
foreach ($rows as $cols) {
// continue on invalid email or empty user guid.
if ( !$form->isEmail($cols[FIELD_EMAIL]) || empty($cols[FIELD_CODE]) )
continue;
$replacements[$cols[FIELD_EMAIL]] = array(
'[EMAIL_CODE]'=>$cols[FIELD_CODE]
);
}
$decorator = new Swift_Plugins_DecoratorPlugin($replacements);
$mailer->registerPlugin($decorator);
//create message
$message = Swift_Message::newInstance()
->setSubject($_POST['title'])
->setFrom(array(FROM_EMAIL => FROM_EMAIL_NAME))
->setReturnPath(FROM_BOUNCE)
->setBody($body, 'text/html');
foreach ($rows as $cols) {
// continue on invalid email or empty user guid.
if ( !$form->isEmail($cols[FIELD_EMAIL]) || empty($cols[FIELD_CODE]) )
continue;
// use full name for recipient if given.
$recipient_name = ( !empty($cols[FIELD_FIRST]) && !empty($cols[FIELD_LAST]) ) ?
$cols[FIELD_FIRST] . ' ' . $cols[FIELD_LAST] : $cols[FIELD_EMAIL];
$message->addTo($cols[FIELD_EMAIL], $recipient_name);
}
$numSent = $mailer->batchSend($message);
I have some code to count the time elapsed and it took 8 seconds to process 5 emails. Am I doing something wrong here?
Some of the anti-spam sendmail settings at smtp.server.tld are:
Code: Select all
define('confMAX_MESSAGE_SIZE', 36700160)dnl
FEATURE(`access_db', `hash -T<TMPF> /etc/mail/access')dnl
FEATURE(`greet_pause',1000)dnl
dnl # Options to help cut down on dictionary attacks
define(`confMAX_RCPTS_PER_MESSAGE',`10')dnl
define(`confBAD_RCPT_THROTTLE',`1')dnl
define(`confCONNECTION_RATE_THROTTLE', `100')dnl
define(`confMAX_DAEMON_CHILDREN', `400')dnl
define(`confTO_ICONNECT', `15s')dnl
define(`confTO_CONNECT', `3m')dnl
define(`confTO_HELO', `2m')dnl
define(`confTO_MAIL', `1m')dnl
define(`confTO_RCPT', `1m')dnl
define(`confTO_DATAINIT', `1m')dnl
define(`confTO_DATABLOCK', `1m')dnl
define(`confTO_DATAFINAL', `1m')dnl
define(`confTO_RSET', `1m')dnl
define(`confTO_QUIT', `1m')dnl
define(`confTO_MISC', `1m')dnl
define(`confTO_COMMAND', `1m')dnl
define(`confTO_STARTTLS', `2m')dnl
define(`confTO_QUEUERETURN', `1d')dnl
define(`confQUEUE_LA', `40')dnl
define(`confREFUSE_LA', `50')dnl
define(`confTO_CONNECT', `15s')dnl
I have my mail server ip set at 0 for greetpause in my access file (fyi.)