9951 explained code solutions for 126 technologies


php-swiftmailerHow to set a BCC address using Swiftmailer?


Swiftmailer is a popular library for sending emails in PHP. To set a BCC address using Swiftmailer, you can use the addBcc() method.

Example code

$message = (new \Swift_Message('Hello World'))
  ->setFrom('[email protected]')
  ->setTo('[email protected]')
  ->addBcc('[email protected]')
  ->setBody('Here is the message itself');

The code above will set the BCC address to [email protected].

Code explanation

Helpful links

Edit this code on GitHub