我认识到,batchEmail是新SwiftMailer不再一部分。 所以我做了这个脚本:
<?
//
// GC PRESS EMAILER v5
//
ini_set('display_errors',1);
error_reporting(E_ALL);
require_once("config.php");
include_once("hawkmail/mail/lib/swift_required.php");
$c=mysql_connect($dbh,$dbu,$dbp);
function SendEmail(){
// DB
$s=mysql_query("SELECT * FROM `newgc`.`press_list`");
// Process Color Listing Loop
while($r=mysql_fetch_array($s)){
// ###########################
// START LOOP
// ###########################
$name=$r['name'];
$email=$r['email'];
$to=array(''.$email.''=>''.$name.'');
include("hawkmail/templates/press.php");
# Email subject
$str=$name;
$str=substr($str, 0, strrpos($str, ' '));
$subject='Dear '.$str.', you are invited to our Exclusive Party Collection Press Day!';
# send message
include("hawkmail/settings.php");
}
// ###########################
// END LOOP
// ###########################
}
SendEmail();
?>
该数据库有200条记录。 我跑了剧本,并将其发送几封电子邮件,然后超时
504网关超时
该name
和email
记录都喜欢
约翰·史密斯John.smith@site.com
很朴实。 而我hawkmail/settings.php
是这样的:
# mail
$smpturl="smtp.sendgrid.net";
$mailu="sitesitesite";
$mailp="sitessssssssssss";
$from=array("no-reply@site.com"=>"site.com");
# login credentials & setup Swift mailer parameters
$transport=Swift_SmtpTransport::newInstance($smpturl, 587);
$transport->setUsername($mailu);
$transport->setPassword($mailp);
$swift=Swift_Mailer::newInstance($transport);
# create a message (subject)
$message=new Swift_Message($subject);
# attach the body of the email
$message->setFrom($from);
$message->setBody($html, 'text/html');
$message->setTo($to);
$message->addPart($text, 'text/plain');
# actually send the message
if($recipients=$swift->send($message, $failures)){}else{}
反正是有增加的PHP时间的限制了(我使用Ubuntu和Nginx的),或者是有没有BatchMail替代()真不明白为什么它已被删除。
使用新的swiftmailer有人可以张贴批量邮件脚本的例子吗?