function sendmail($setEmail, $setName, $body, $subject) { require_once("PHPMail/phpmailer.php"); $mail = new PHPMailer ( true ); // the true param means it will throw exceptions on errors, which we need to catch $mail->IsSMTP (); // telling the class to use SMTP try { $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = SBT_SSL; // sets the prefix to the servier $mail->Host = SBT_SMTP_HOST; // sets GMAIL as the SMTP server $mail->Port = SBT_SMTP_PORT; // set the SMTP port for the GMAIL server $mail->Username = SBT_SMTP_USER; // GMAIL username $mail->Password = SBT_SMTP_PASS; // GMAIL password $mail->AddReplyTo ( SBT_MAIL_FROM, SBT_MAIL_FROM_NAME ); $mail->AddAddress ( $setEmail, $setName ); $mail->SetFrom (SBT_SMTP_USER,SBT_SMTP_USER); //sender name $mail->Subject = $subject; $mail->MsgHTML ( $body ); if (! $mail->Send ()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit (); } } catch ( phpmailerException $e ) { echo $e->errorMessage (); //Pretty error messages from PHPMailer } catch ( Exception $e ) { echo $e->getMessage (); //Boring error messages from anything else! }
require_once("PHPMail/phpmailer.php");
$mail = new PHPMailer ( true ); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP (); // telling the class to use SMTP
try {
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = SBT_SSL; // sets the prefix to the servier
$mail->Host = SBT_SMTP_HOST; // sets GMAIL as the SMTP server
$mail->Port = SBT_SMTP_PORT; // set the SMTP port for the GMAIL server
$mail->Username = SBT_SMTP_USER; // GMAIL username
$mail->Password = SBT_SMTP_PASS; // GMAIL password
$mail->AddReplyTo ( SBT_MAIL_FROM, SBT_MAIL_FROM_NAME );
$mail->AddAddress ( $setEmail, $setName );
$mail->SetFrom (SBT_SMTP_USER,SBT_SMTP_USER); //sender name
$mail->Subject = $subject;
$mail->MsgHTML ( $body );
if (! $mail->Send ()) {
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit ();
}
} catch ( phpmailerException $e ) {
echo $e->errorMessage (); //Pretty error messages from PHPMailer
} catch ( Exception $e ) {
echo $e->getMessage (); //Boring error messages from anything else!
}
但人家的服务器是专业的邮件服务器,稳定啊。
你的服务器sendmail,别说上千任务了,几百个就卡了。
怎么办?说一说 我的无耻的办法。申请了100个126的号(实际远远不止100个,机器申请嘛,具体多少我就不说了)。
做成数组,每次发邮件rand其中一个。如果126限制每个号一天200个邮件,那么100个号
就可以发2w个邮件。而且phpmailer类,可以抄送,一次可以发50封。 嘿嘿 还行吧
smtp 发信速度有点慢,但是基本上很少有延时,用sendmail 发信 经常今天发的信 明天或后天才收到。看自己情况吧 如果 邮件不多 就照上面那位老兄的办法 申请个100来个 126邮箱 随机发 ,不过这个弊端就是,不能设置自己的发件人,发出的邮件的发件人都是126的,没法带自己公司域名后缀用系统的发 就可以设置发件人,可以写成自己公司的邮箱,客户看起来舒服些。