9951 explained code solutions for 126 technologies


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


Swiftmailer allows you to set the default 'from' address for all emails sent using the library. This can be done by setting the from property of the message object.

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

The setFrom() method takes two parameters:

  1. $address - The email address of the sender.
  2. $name - The name of the sender (optional).

For more information, please refer to the Swiftmailer documentation.

Edit this code on GitHub