Home » Php » php – How to set reply-to when using Swiftmailer

php – How to set reply-to when using Swiftmailer

Posted by: admin April 23, 2020 Leave a comment


How can reply-to be set when using Swiftmailer. The docs mentioned the function setReplyTo() but without specific instructions on how to use it.

Any help will be appreciated.

How to&Answers:

I can confirm that the setReplyTo method works the same way as (for example) the setCC method.

  '[email protected]',
  '[email protected]' => 'Person 2 Name',
  '[email protected]',
  '[email protected]',
  '[email protected]' => 'Person 5 Name'


For those who experienced the same confusion as me, you are not able to run $recipients->setReplyTo() on a Swift_RecipientList but you are able to do so on the Swift_Message directly:

$recipients = new Swift_RecipientList;
// this is correct
$recipients->addTo('[email protected]');
// this method does not exist so this does not work
$recipients->addReplyTo('[email protected]');

$message = new Swift_Message($subject, $message, 'text/html');
// you can, however, add the reply-to here like this
$message->setReplyTo('[email protected]');
// and of course sending the e-mail like this with the reply to works
$swift->send($message, $recipients, '[email protected]');