如何解决我的问题,当我发送电子邮件时,使用阿里巴巴直邮总是去垃圾邮件,我使用 laravel 发送邮件。
protected function SendEmail($toData,$EmailData)
{
$to_name=$toData['to_name'];
$to_email=$toData['to_email'];
$subject=$EmailData['subject'];
try {
Mail::send($EmailData['view'], $EmailData['data'], function($message) use ($to_name, $to_email,$EmailData) {
$message->to($to_email, $to_name)
->subject($EmailData['subject']);
$message->from(env('MAIL_FROM_ADDRESS'), env('MAIL_FROM_NAME'));
});
$json['STATUS'] = 'SUCCESS';
$json['MESSAGE'] = 'EMAIL SENT SUCCESSFULLY!';
} catch (\Swift_TransportException $transportExp) {
if( count(Mail::failures()) > 0 ) {
foreach(Mail::failures as $email_address) {
$DATA['failed']=" - $email_address <br />";
$result[]=$data;
}
$json['STATUS'] = 'FAILED';
$json['MESSAGE'] = 'FAILED TO SEND EMAIL '.$result;
} else {
$json['STATUS'] = 'SUCCESS';
$json['MESSAGE'] = 'EMAIL SENT SUCCESSFULLY!';
}
}
return json_encode($json);
}