【问题标题】:Yii framework SMTP mail with gmail from email id not changedYii 框架 SMTP 邮件与来自电子邮件 ID 的 gmail 未更改
【发布时间】:2014-07-01 11:13:05
【问题描述】:

我正在使用此扩展程序。 http://www.yiiframework.com/extension/smtp-mail

我会正常工作。但未设置我在 "SetFrom()" 函数中定义的邮件中的电子邮件 ID,但它需要 Gmail 用户名 (myemail@gmail.com)。

以下是我在控制器中发送邮件的代码。

 $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'
        ),

【问题讨论】:

  • 您为$mail 对象设置的确切值是多少? "otherid" 实际上是一些电子邮件 ID 对吗?
  • $mail 对象首先加载我的扩展类。然后分配 to, from , from name 和 msg.

标签: php email yii phpmailer


【解决方案1】:

如果电子邮件未注册到主要 gmail 帐户,Gmail 似乎不允许通过不同的电子邮件 ID 发送电子邮件。

  1. 登录到primary gmail account -> 转到Account 选项卡(右上角)。

  2. Send mail as 下搜索Add another email address

    在那里添加新的电子邮件地址。确认发送到其他电子邮件帐户的链接。

  3. 确认后,您的帐户可以从任一地址发送电子邮件。

现在在$mail->SetFrom("new_gmail_id@gmail.com", $from_name); 中尝试新的电子邮件地址,它会正常工作。

我已经尝试过了,它确实有效。如果您已经完成了所有这些,请告诉我们。

【讨论】:

    猜你喜欢
    • 2012-12-31
    • 2014-06-23
    • 2022-06-18
    • 2015-06-22
    • 2021-03-04
    • 2013-07-04
    • 1970-01-01
    • 2017-02-09
    • 2014-10-19
    相关资源
    最近更新 更多