yii2 如何防止 swiftmailer 将电子邮件发送到垃圾邮件文件夹

yii2 how to prevent swiftmailer from sending email to spam folder

如何防止swiftmailer将邮件发送到垃圾邮件文件夹 我是这样使用它的:

        Yii::$app->mailer->compose()
          ->setFrom($sender_email)
          ->setTo($reciver)
          ->setSubject($subject)
          ->setTextBody($body)
          ->setHtmlBody($hml)
          ->send();

使用一些header

Reference

$message = Yii::$app->mailer->compose(...);
$message->getSwiftMessage()->getHeaders()->addTextHeader('name', 'value');

另见this