9951 explained code solutions for 126 technologies


php-swiftmailerHow to set the sender name in SwiftMailer?


SwiftMailer allows you to set the sender name in the message header. To do this, you need to use the setFrom() method.

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

This will set the sender name to "John Doe" and the sender address to "[email protected]".

The setFrom() method takes two parameters:

  1. The sender address - This is the email address of the sender.
  2. The sender name - This is the name of the sender that will be displayed in the message header.

Helpful links

Edit this code on GitHub