PhpMailer-无法将新闻通讯发送给大量订户 [英] PhpMailer - Cannot send newsletter to large amount of subscribers

查看:175
本文介绍了PhpMailer-无法将新闻通讯发送给大量订户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里有个大问题! 我需要向所有订阅者发送新闻通讯(大约1200) 问题是,它只会将新闻简讯发送给其中的150-180. 我有一个用php实现的脚本,该脚本使用PhpMailer()类将新闻稿发送给所有订阅者.

Im having a big problem here! I need to send a newsletter to all my subscribers (around 1200) The thing is that it only sends the newsletter to 150-180 of them. I have a script implemented in php that uses the PhpMailer() class to send the newsletter to all the subscribers.

我在MailJet中购买了一个计划,该计划允许我每月发送3万封电子邮件,因此我使用他们的SMTP主机发送新闻稿.

I purchased a plan in MailJet that allows me to send 30 thousand emails per month, so Im using their SMTP host to send the newsletter.

这是我的剧本:

$mail             = new PHPMailer();
$body             = $message;
$body             = eregi_replace("[\]",'',$body);

$mail->IsSMTP();
$mail->SMTPAuth   = true;
$mail->Host       = "in.mailjet.com";
$mail->Port       = 80;
$mail->Username   = "username";
$mail->Password   = "password";

// thing regarding the body, subject, etc of the email //

$to_list = explode(',',$to);
$between_delay = 75; //max limit of mails send at a slot
$send_count = 1; 
$send_delay = 1; //Delays the program execution for the given number of seconds.

ignore_user_abort(true); // Ignore user aborts and allow the script to run forever
set_time_limit(300); //to prevent the script from dying

foreach($to_list as $row){
    if ( ($send_count % $between_delay) == 0 ){
        sleep( $send_delay ); //Delays the program execution for the given number of seconds.
    }
    $address = $row;
    if(!empty($address)) {
        $mail->AddAddress($address, "User");
        $mail->Send();
        $mail->ClearAddresses(); //clear address
   }
   $send_count++;
}

if(!empty($mail->ErrorInfo)) {
     // display an error
}

我真的不知道可能是什么问题,但是由于某种原因,它停止在大约180号之后发送电子邮件. 可能与 set_time_limit(300); ??

I really dont know what may be the problem but for some reason it stops sending emails after the number 180 approximately. Could it be something regarding the set_time_limit(300); ??

推荐答案

我不建议将新闻通讯的副本发送到每个电子邮件地址;这会浪费带宽,并迫使您的脚本发送邮件的多个副本.

I don't recommend sending a copy of the newsletter to each individual email address; it wastes bandwidth and forces your script to send multiple copies of the message.

相反,请考虑使用SMTP服务器的密件抄送(BCc)功能发送大量电子邮件.这样一来,您的SMTP服务器就可以优化新闻简报的发送,并且还可以节省带宽.

Instead, consider using the blind-carbon-copy (BCc) feature of your SMTP server to send the mass email. This will allow your SMTP server to optimize the delivery of the newsletter, and it will save you bandwidth as well.

快速查看PHPMailer API,您可以使用$mailer->AddBCC()函数添加BCc地址.例如,$php_mailer->AddBCC('somebody@example.com', 'Joe Somebody');应该可以工作.

A quick lookup of the PHPMailer API says you can add BCc'd addresses using the $mailer->AddBCC() function. For example, $php_mailer->AddBCC('somebody@example.com', 'Joe Somebody'); should work.

这篇关于PhpMailer-无法将新闻通讯发送给大量订户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆