douyannuo7733 2014-07-01 11:13
浏览 38

Yii框架SMTP邮件与电子邮件ID中的Gmail没有更改

I am using this extension. http://www.yiiframework.com/extension/smtp-mail

I would work properly. But From Email id in mail not set that i have defined in "SetFrom()" function but it takes Gmail username (myemail@gmail.com).

Below is my code for sending mail in my Controller.

 $mail = Yii::app()->Smtpmail;
 $mail->SetFrom("otherid",$from_name); // This id not coming in  my response mail
 $mail->Subject = $subject;
 $mail->MsgHTML($message);
 $mail->AddAddress($to, "");

config/main.php

'Smtpmail'=>array(
            'class'     => 'application.extensions.smtpmail.PHPMailer',
            'Host'      => "smtp.gmail.com",
            'Username'  => 'myemail@gmail.com',
            'Password'  => 'password',
            'Mailer'    => 'smtp',
            'Port'      => 465,
            'SMTPAuth'  => true,
            'SMTPSecure' => 'ssl'
        ),
  • 写回答

1条回答 默认 最新

  • duanjingsen7904 2014-07-01 12:28
    关注

    Gmail doesn't seem to allow sending the email via a different email-id if its not registered to the primary gmail account.

    1. When logged in to the primary gmail account -> go to Account tab (top-right).

    2. Search for Add another email address under Send mail as.

      Add the new email address there. Confirm the link sent to the additional email account.

    3. On confirmation, your account can send emails from either of the address.

    Try the new email address now in $mail->SetFrom("new_gmail_id@gmail.com", $from_name); and it will work fine.

    I have tried that and it works. Let us know if you have done all this already.

    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀