【问题标题】:SERVER -> CLIENT: 452 4.5.3 Error: too many recipients服务器 -> 客户端:452 4.5.3 错误:收件人太多
【发布时间】:2021-06-09 14:08:29
【问题描述】:

亲爱的 Goblin Slayers(开发人员),我已经尝试解决这个问题两天了。我正在尝试为基于 PHP 邮件程序的公司构建一个用于营销目的的邮件程序,当我们发送 HTML 时,我的代码运行良好将文件发送给 6-8 个(或多或少)个收件人,但是当我们尝试通过我的 localhost 将 HTML 文件发送给超过 100 个收件人时,我收到以下错误:

2021-03-12 14:10:30 SMTP INBOUND: "452 4.5.3 Error: too many recipients"
2021-03-12 14:10:30 SERVER -> CLIENT: 452 4.5.3 Error: too many recipients

我的代码如下:

<?php

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

require_once 'folder/dbh.inc.php';
include 'folder/index.inc.php';

$content = file_get_contents('body_file.html');

// An array that contains the List of recipients

$emailst = array("100-500 recipients");

$emailst_length = count($emailst) - 1;

//Load Composer's autoloader
require 'vendor/autoload.php';


//Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);

try {
    
    require 'folder/credentials.inc.php';


    //Recipients
    $mail->setFrom('emailOfTheCompany.com', 'company name');
    $mail->addAddress('another email of the company', 'company name');
    
    for ($i=0; $i <= $emailst_length; $i++) { 
        $mail->addBCC($emailst[$i]);
    }

//Content
    $mail->isHTML(true);                                  //Set email format to HTML
    $mail->CharSet = 'utf-8';
    $mail->Subject = 'Welcome To Subject';
    $mail->Body    = $content;
    //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}

?>

【问题讨论】:

    标签: php email client-server phpmailer contact-form


    【解决方案1】:

    此错误返回给发件人,表示分发列表太大。设置这些限制的原因是为了防止用户发送垃圾邮件。如果列表中的姓名过多,您的电子邮件可能会被标记为垃圾邮件并被视为垃圾邮件。

    防止此错误的最简单方法是创建具有合理数量的电子邮件地址的分发列表。尽可能少于 25 个收件人,但您的服务器可能允许每个列表中有 50 到 75 个收件人。

    您可以通过查看 SMTP 服务器文档或您的 ISP 来了解发送电子邮件的限制。

    【讨论】:

    • 谢谢你,我考虑你的意见。
    • 我想我现在应该解决这个问题,并找到一种方法,在每次发送操作中将收件人列表最小化为 25 个收件人,直到我们数据库中的每个收件人都收到电子邮件,以便让服务器相信我们的列表不是太大。也许条件循环可以正常工作
    • 没错!好主意。如果有帮助,请不要犹豫,接受我的回答。
    猜你喜欢
    • 1970-01-01
    • 2010-11-23
    • 1970-01-01
    • 2013-05-24
    • 2018-06-02
    • 2021-12-04
    • 2017-07-02
    • 2022-06-16
    • 1970-01-01
    相关资源
    最近更新 更多