9951 explained code solutions for 126 technologies


php-swiftmailerHow to set the 'from' address in Swiftmailer?


The 'from' address in Swiftmailer can be set using the setFrom() method.

$message->setFrom('[email protected]', 'Sender Name');

The setFrom() method takes two parameters:

  1. The email address of the sender.
  2. The name of the sender.

The setFrom() method should be called before the send() method.

For more information, please refer to the Swiftmailer documentation.

Edit this code on GitHub