Gooday mam / sir
我在laravel sendmail中遇到问题。邮件发送到垃圾邮件文件夹。对于此类问题,我非常感激任何帮助。顺便说一句,我使用smtp发送电子邮件
这是我的配置:
在我的helpers.php中
Mail::send($data['template'], $data, function ($message)
use ($sourceEmail, $header, $cc, $receiver, $file, $name, $subject)
{
if($file != null){
$message->attach($file->getRealPath(),
[
'as' => $file->getClientOriginalName(),
'mime' => $file->getClientMimeType(),
]);
}
$message->from($sourceEmail);
if(count($cc) > 0){
$message->cc($cc);
}
if($name != null){
$message->to($receiver, $name)->subject($subject);
}else{
$message->to($receiver)->subject($subject);
}
});
if(count(Mail::failures()) > 0){
$response = array(
'success' =>false,
'data' => Mail::failures(),
);
} else {
$response = array(
'success' =>true,
);
}
return $response;
在我的控制器中:
$data = array(
'receiver' => $email,
'messagecontent' => $message,
'file' => $file,
'subject' => ' Subscriber',
'template' => 'front.bulk-email',
);
$resultEmail = sendEmails(
$data, // data in which render into view
'company@gmail.com', //source email
'Subscriber', //header
);
在我的模板中
<div class="col-md-12">
<h3>
Good day Subscriber,
</h3>
@if(!empty($messagecontent))
{{ $messagecontent }}
@else
<p>
Thank you for subscribing at electricphil. You will receive the latest news and products.
</p>
@endif
<hr>
我的.env配置看起来不错,所以这里不包括我的配置 我已经在https://www.smtper.net/中使用.env中的凭据对其进行了测试 及其工作正常。