dongyuyi5680 2014-12-03 08:17
浏览 33
已采纳

在YiiMailer中添加标题标记

Problem

While Sending Mail via Postfix and through Amazon SES it throws me a ,

554 Message rejected: Email address is not verified.

Error message, And i have verified my From Email address and Amazon SES is in the production environment , so no issue there. This is what Amazon documentation says :

Email address is not verified—Your account is in the sandbox and one of the recipient email addresses has not been verified. This might apply to "Sender", "Return-Path", or "From" addresses.

If you have not requested production access to Amazon SES, you must verify every recipient email address except for the recipients provided by the Amazon SES mailbox simulator. You must also verify your own "From" address. For more information, see Verifying Email Addresses and Domains in Amazon SES and Testing Amazon SES Email Sending.

SO, After searching for solution i found out a BLOG POST explaining the fix for this issue, which says adding -f flag in email will solve this issue,

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: michael@chtoen.com' . "
" .
    'Return-Path: michael@chtoen.com' . "
" .
    'Reply-To: michael@chtoen.com' . "
";
mail($to, $subject, $message, $headers, '-f michael@chtoen.com');
?>

Which actually does solve the issue, But I cannot set it to the YiiMailer. For now i am adding this flag directly to php.ini as ,

sendmail_path to usr/sbin/sendmail -t -i -f "noreply@sbworkbench.com"

It works fine. But I don't want to do it this way.

What I have done

Is , Create the YiiMailer setup as ,

$mail = new YiiMailer('customerEmail', $data);
Common::setup_smtp($mail);
$mail->setLayout('mail');
$mail->render();
$mail->From = Yii::app()->params['adminEmail'];
$mail->FromName = 'PENDING NOTIFICATION';
$mail->Subject = $data['subject'];
$mail->AddAddress($data['sendTo']);

And for adding the flag I have tried ,

  1. Adding the flag itself in the From address : Results the same invalid email

    $mail->From= "-f exaple@example.com"

  2. Adding extra parameters "Form" with value as "-f exaple@example.com" : Results Duplicate Form Address (which is obvious :D)

Question :

  1. How can I set header flag using YiiMailer ?
  2. Is it related to misconfiguration of Postfix with Amazon SES ? However, The same setting is working fine for Java Application.

P.S

  1. The code works on sendmail and swiftmail without Amazon SES with no need of the header flag.
  • 写回答

1条回答 默认 最新

  • dqzuo0327 2014-12-04 07:45
    关注

    YiiMailer is a wrapper for PHPMailer. You can set the -f flag by setting the $Sender property of PHPMailer.

    $mail->Sender = "michael@chtoen.com"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 php 将rtmp协议转hls协议,无法播放
  • ¥15 miniconda安装不了
  • ¥20 python代码编写
  • ¥20 使用MPI广播数据遇到阻塞
  • ¥15 TinyMCE如何去掉自动弹出的“链接…”工具?
  • ¥15 微信支付转账凭证,如何解决
  • ¥15 在win10下使用指纹登录时,界面上的文字最后一个字产生换行现象
  • ¥20 使用AT89C51微控制器和MAX7219驱动器来实现0到99秒的秒表计数,有开始和暂停以及复位功能,下面有仿真图,请根据仿真图来设计c语言程序
  • ¥15 51单片机 双路ad同步采样
  • ¥15 使用xdocreport 生成word