douqin6785 2019-02-27 09:29
浏览 384

如何从phpmailer获取错误列表?

I'm sending emails through PHPMailer and I found a specific case when the email address is a non-existing email address that belongs to the sending gateway [ e.g - gateway email: 1234@1234.com and the email address 0000@1234.com], phpmailer returns the following error: "Recipient address rejected user unknown in virtual mailbox table".

It would be great if a status code might be present there (I want to know if is a hard bounce or a soft bounce) and also, I want to know what kind of other specific cases might occur.

  • 写回答

1条回答 默认 最新

  • douyi2798 2019-02-27 11:49
    关注

    SMTP errors are covered by RFC5321 and related RFCs, and you can see most significant errors codes there. When you get an SMTP error in PHPMailer, the SMTP error code is put in the $error property of the SMTP instance, which is protected, but you can fetch it using getError(). From normal PHP code this would be done with:

    $error = $mail->getSMTPInstance()->getError();
    

    The result is an array like this:

    [
        'error' => $message,
        'detail' => $detail,
        'smtp_code' => $smtp_code,
        'smtp_code_ex' => $smtp_code_ex,
    ]
    

    The thing that will be of most interest to you is the smtp_code element.

    Note that this only applies when you're sending via SMTP; if you're sending via mail(), this won't be populated.

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP