phpmailer更改邮件发件人 [英] phpmailer change mail sender
问题描述
当我从phpmailer发送邮件并且想要回复时,我得到了回复电子邮件地址,例如admin@domain.com.但我想将其更改为office@domain.com. 所以我加了:
When I send mail from phpmailer and I wanted to response I get response e-mail address like admin@domain.com. But I want change it to office@domain.com. So I added:
$mail->AddReplyTo('office@domain.com', 'First Last');
但是在回复电子邮件中,我同时收到了(办公室和管理员),并且我只想要office@domain.com 我将其更改为:
But in e-mails to response I get both (office and admin) and I want only office@domain.com I changed it to:
$mail->Sender='admin@domain.pl';
$mail->SetFrom('office@domain.pl','First Last');
我知道
SMTP Error: Data not accepted.
SMTP server error: 5.7.1 Forged sender address:
我的phpmailer版本是:5.2.6
My phpmailer version is: 5.2.6
推荐答案
对回复的地址需要在发件人地址之前添加:
The reply to addresses needed to be added before the from address:
$mail->addReplyTo('replyto@email.com', 'Reply to name');
$mail->setFrom('mailbox@email.com', 'Mailbox name');
按此顺序,一切正常.
addReplyTo 而不是 AddReplyTo
addReplyTo not AddReplyTo
替代: 您可以在以下之前清除replyTo数组:
Alternative: You can clear replyTo array before:
$mail->ClearReplyTos();
$mail->addReplyTo(example@example.com, 'EXAMPLE');
这篇关于phpmailer更改邮件发件人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!