代码之家  ›  专栏  ›  技术社区  ›  Adam

从Mailable获取坏域名

  •  0
  • Adam  · 技术社区  · 7 年前

    我和拉威尔一起发邮件的时候是这样的:

    foreach ($users as $user) {
       \Mail::to($user())->send(new Newsletter($user));
    }
    

    我想有一个数组的所有用户谁有一个坏的域响应。我发现在 docs 拉威尔用的是有 a way to find bad_domain respones

    // Pass a variable name to the send() method
    if (!$mailer->send($message, $failures))
    {
      echo "Failures:";
      print_r($failures);
    }
    
    /*
    Failures:
    Array (
      0 => receiver@bad-domain.org,
      1 => other-receiver@bad-domain.org
    )
    */
    

    有没有什么简单的方法来获取坏域名时,使用邮寄从拉威尔?

    1 回复  |  直到 7 年前
        1
  •  0
  •   Adam    7 年前

    你只能访问坏域名,但不能用Swiftmailer跳转( Swiftmailer 4 does not retrieve bounces as $failedRecipients ).

    错误的\u域 它与

    \Mail::to($user)->send(new \App\Mail\Hi());
    
    dd(\Mail::failures());
    

    看到了吗 Illuminate\Mail\Mailer.php

      /**
         * Send a Swift Message instance.
         *
         * @param  \Swift_Message  $message
         * @return void
         */
        protected function sendSwiftMessage($message)
        {
            try {
                return $this->swift->send($message, $this->failedRecipients);
            } finally {
                $this->forceReconnection();
            }
        }