使用 Swiftmailer 时如何设置回复。文档提到了函数setReplyTo()但没有关于如何使用它的具体说明。
任何帮助将不胜感激。
我可以确认该setReplyTo
方法的工作方式与(例如)setCC方法相同。
$message->setReplyTo(array(
'person1@example.org',
'person2@otherdomain.org' => 'Person 2 Name',
'person3@example.org',
'person4@example.org',
'person5@example.org' => 'Person 5 Name'
));
对于那些和我有同样困惑的人,你不能$recipients->setReplyTo()
在 Swift_RecipientList 上运行,但你可以直接在 Swift_Message 上运行:
$recipients = new Swift_RecipientList;
// this is correct
$recipients->addTo('some@email.com');
// this method does not exist so this does not work
$recipients->addReplyTo('some.other@email.com');
$message = new Swift_Message($subject, $message, 'text/html');
// you can, however, add the reply-to here like this
$message->setReplyTo('some.other@email.com');
// and of course sending the e-mail like this with the reply to works
$swift->send($message, $recipients, 'some@email.com');