当使用Swiftmailer时,如何设置回复地址(reply-to)。文档中提到了函数setReplyTo(),但没有具体的使用说明。
欢迎任何帮助和支持。
当使用Swiftmailer时,如何设置回复地址(reply-to)。文档中提到了函数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'
));
如果你和我一样感到困惑,那么你无法在Swift_RecipientList上运行$recipients->setReplyTo()
,但是你可以直接在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');