【问题标题】:How to change from email address in smtp php mailer function sendmail()如何在 smtp php 邮件程序函数 sendmail() 中更改电子邮件地址
【发布时间】:2016-02-04 11:47:30
【问题描述】:

我正在使用下面的代码,我收到了电子邮件,但不是来自setFrom() 函数的电子邮件地址。谁能帮我在 SMTP sendmail() 函数中设置电子邮件地址的愿望?

include_once 'Mailer.php'; 

$body = 'TEST, Testing of email.';
$subject = 'Email Demo';
$email = 'test1@gmail.com';
$fromEmail = 'test2@gmail.com';    

$objMail = new Mailer();
$objMail->mail->AddReplyTo('test3@gmail.com', 'Test 3');
$objMail->mail->SetFrom('testfrom1@gmail.com', 'Test From 1');
$objMail->mail->AddAddress('test4@gmail.com', 'Test 4');
$objMail->mail->IsHTML(true);

$objMail->sendmail($email, 'Test', $subject, $body);

【问题讨论】:

    标签: php email smtp phpmailer


    【解决方案1】:

    这个问题已经回答过很多次了。 Gmail 不允许您设置任意地址,但您可以在帐户中添加有限数量的预配置别名。

    【讨论】:

    • 我应该使用hotmail帐户和hotmail live smtp配置吗?
    • 试试看,但请注意,设置任意地址通常是个坏主意,如果您伪造任何东西,您的邮件可能会被 SPF 拒绝。
    猜你喜欢
    • 2018-04-30
    • 1970-01-01
    • 2020-08-16
    • 1970-01-01
    • 1970-01-01
    • 2014-04-30
    • 2016-10-14
    • 1970-01-01
    • 2011-03-11
    相关资源
    最近更新 更多