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.