如何在smtp php mailer函数sendmail()中更改电子邮件地址


How to change from email address in smtp php mailer function sendmail()

我正在使用下面的代码,我收到了电子邮件,但电子邮件地址不是来自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);

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

相关文章: