Swiftmailer仅从BCC发送999封电子邮件 [英] Swiftmailer only sends 999 emails from BCC

查看:263
本文介绍了Swiftmailer仅从BCC发送999封电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Swiftmailer PHP 版本4.3.0,我想在密件抄送中发送一封包含1500个电子邮件地址的电子邮件

I am using Swiftmailer PHP Version 4.3.0 and I want to send one email with 1500 email addresses in the BCC.

服务器的限制允许我在24小时内最多发送10000封电子邮件。我尚未超过此限制。

The limits on my server allow that I can send up to 10000 emails within 24h. I have not exceeded this limit.

但是,当我尝试使用Swiftmailer发送电子邮件时,它会返回以下错误消息(有关详细信息,请参见下文)

However, when I try to send the email with Swiftmailer it returns the following error message (see below for details)


421连接中的邮件过多'

"421 too many messages in this connection "'

并且密件抄送中1500个电子邮件地址中只有999封电子邮件会收到该电子邮件。
我多次执行了此实验,还将BBC中的电子邮件数量更改为1000或2000-每次准确通过999封电子邮件。 Swiftmailer中是否有某个限制,不允许在密件抄送中设置超过999个电子邮件地址?如果是这样,是否可以更改此限制?如果不是,还有什么可能导致此问题?

and only 999 emails from the 1500 email addresses in the BCC receive the email. I executed this experiment several times, also changing the number of emails in the BBC to 1000 or 2000 - each time exactly 999 emails go through. Is it possible that there is a limit somewhere in Swiftmailer which does not allow to set more then 999 email addresses in the BCC? If so, is it possible to change this limit? If not, what else could cause this problem?

以下是来自Swiftmailer的完整错误消息:

Here is the complete error message from Swiftmailer:


异常 Swift_TransportException,消息为预期响应
,代码为250,但代码为 421,消息为: $ b $中的消息太多 b此连接'在
/is/htdocs/www/swift/lib/classes/Swift/Transport/AbstractSmtpTransport.php:386
堆栈跟踪中:

exception 'Swift_TransportException' with message 'Expected response code 250 but got code "421", with message "421 too many messages in this connection "' in /is/htdocs/www/swift/lib/classes/Swift/Transport/AbstractSmtpTransport.php:386 Stack trace:

#0 /is/htdocs/www/swift/lib/classes/Swift/Transport/AbstractSmtpTransport.php(281):
Swift_Transport_AbstractSmtpTransport-> _ assertResponseCode('421也是
我很多。 。',数组)

#0 /is/htdocs/www/swift/lib/classes/Swift/Transport/AbstractSmtpTransport.php(281): Swift_Transport_AbstractSmtpTransport->_assertResponseCode('421 too many me...', Array)

#1 /is/htdocs/www/swift/lib/classes/Swift/Transport/EsmtpTransport.php(245):
Swift_Transport_AbstractSmtpTransport-> executeCommand('MAIL FROM:
executeCommand('MAIL FROM:_doMailFromCommand('me@mydomain.n ...')

#1 /is/htdocs/www/swift/lib/classes/Swift/Transport/EsmtpTransport.php(245): Swift_Transport_AbstractSmtpTransport->executeCommand('MAIL FROM: executeCommand('MAIL FROM: _doMailFromCommand('me@mydomain.n...')

#4 /是/ htdocs / www / swift / lib / classes / Swift / Transport / AbstractSmtpTransport。 php(466):
Swift_Transport_AbstractSmtpTransport-> _ doMailTransaction(Object(Swift_Message),
'me@mydomain.n ...',Array,Array)

#4 /is/htdocs/www/swift/lib/classes/Swift/Transport/AbstractSmtpTransport.php(466): Swift_Transport_AbstractSmtpTransport->_doMailTransaction(Object(Swift_Message), 'me@mydomain.n...', Array, Array)

#5 /is/htdocs/www/swift/lib/classes/Swift/Transport/AbstractSmtpTransport.php(178):
Swift_Transport_AbstractSmtpTransport-> _ sendBcc(Object(Swift_Message),
'me @ mydomain.n ...',数组,数组)

#5 /is/htdocs/www/swift/lib/classes/Swift/Transport/AbstractSmtpTransport.php(178): Swift_Transport_AbstractSmtpTransport->_sendBcc(Object(Swift_Message), 'me@mydomain.n...', Array, Array)

#6 /is/htdocs/www/swift/lib/classes/Swift/Mailer.php(86) :Swift_Transport_AbstractSmtpTransport-> send(Object(Swift_Message),
数组)

#6 /is/htdocs/www/swift/lib/classes/Swift/Mailer.php(86): Swift_Transport_AbstractSmtpTransport->send(Object(Swift_Message), Array)

#7 /is/htdocs/www/swift/lib/swift_required.php(133 ):Swift_Mailer-> send(Object(Swift_Message))

#7 /is/htdocs/www/swift/lib/swift_required.php(133): Swift_Mailer->send(Object(Swift_Message))

#8 /is/htdocs/www/mydomain.net/test.php(21):sendMessage()

#8 /is/htdocs/www/mydomain.net/test.php(21): sendMessage()

#9 {main}

执行以下代码时:

/*
 * Autoloader and dependency injection initialization for Swift Mailer.
 */

if (defined('SWIFT_REQUIRED_LOADED')) {
    return;
}

define('SWIFT_REQUIRED_LOADED', true);

//Load Swift utility class
require dirname(__FILE__) . '/classes/Swift.php';

if (!function_exists('_swiftmailer_init')) {
    function _swiftmailer_init()
    {
        require dirname(__FILE__) . '/swift_init.php';
    }
}

//Start the autoloader and lazy-load the init script to set up dependency injection
Swift::registerAutoload('_swiftmailer_init');

sendMessage();

function sendMessage(){

try{

  // LARGE ARRAY with 1500 entries
  $bcc = array("test1@mydomain.net","test2@mydomain.net", ... , "test1500@mydomain.net")

  // Create the Transport
  $transport = Swift_SmtpTransport::newInstance('***', 25);
  $transport->setUsername('***');
  $transport->setPassword('***');

  // Create the Mailer using your created Transport
  $mailer = Swift_Mailer::newInstance($transport);

  // Create the message
  $message = Swift_Message::newInstance();

  // Give the message a subject
  $message->setSubject("This is a test mail");

  // Set the From address with an associative array
  $message->setFrom(array('me@mydomain.net' => 'My Name'));

  $message->setTo("specialMail@mydomain.net");

  $message->setBcc($bcc);

  $message->setBody("Hi, this is a test mail. Enjoy.");

  $result = $mailer->send($message);

  echo "Success";
}
catch(Exception $exception)
{
  echo $exception;
}
}


推荐答案

消息来自远程SMTP服务器。您的邮件托管帐户每天可能接受10000条消息,但这与您可能具有的其他限制(收件人总数,每条消息的收件人,每条连接的消息,消息大小,允许的发件人...)完全无关。

That message comes from the remote SMTP server. Your mail hosting account may accept 10000 messages per day but that is totally unrelated to other limits you might have (total recipients, recipients per message, messages per connection, message size, allowed senders...).

密件抄送在内部通过发送单个消息(每个收件人一个)来工作,因此这样做有一定的局限性。

Bcc works internally by sending individual messages, one per recipient, so it's sensible to hit some limits doing so.

很难将收件人列表分成几部分并发送几份消息:

It shouldn't be difficult to split your recipient list in chunks and send several copies of the message:

$all_bcc = array("test1@mydomain.net","test2@mydomain.net", ... , "test1500@mydomain.net");

foreach (array_chunk($all_bcc, 999) as $bcc) {
    $transport = Swift_SmtpTransport::newInstance('***', 25);
    $transport->setUsername('***');
    // ...
}

这篇关于Swiftmailer仅从BCC发送999封电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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