1

I using hotmail and send mail from laravel 5.8:

           try{
            Mail::send([], [], function($message) use ($mailto, $mailtitle, $body, $pathToFile) {
                $message->from(env('MAIL_USERNAME'), env('MAIL_FROM_NAME'));
                $message->subject($mailtitle);

                if ($pathToFile != "")
                    $message->attach($pathToFile);
                $message->setBody($body, 'text/html');
                $message->to(explode(",", $mailto));
            });              
            // check for failures
            if (Mail::failures()) {
                $return["status"] = "NG";
                $return["error"] = "Can't send mail.";
            }
            else{
               $return["status"] = "OK";
            }
         } catch (\Exception $ex) {           
            $return["status"] = "NG";
            $return["error"] = $ex->getMessage();
         }

I had attach a file txt has content (test file is virus):

X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*

Mail can't send, but it not show any message.

How can detect the result of send mail by Hotmail?

With Gmail it will occur a exception.

D T
  • 3,522
  • 7
  • 45
  • 89
  • put your content in **try catch** for exception. – mitesh Sep 16 '19 at 04:10
  • i had put in try catch, hotmail not occur exception, only gmail occur exception. – D T Sep 16 '19 at 04:14
  • The mail servers of such a provider do not necessarily give you an immediate failure response. There is little you can do about that at this point. You can try and check if you get any _bounce_ mails containing errors, but that has to happen outside of the sending process, and is more complex. – 04FS Sep 16 '19 at 07:25

0 Answers0