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
\Swift_Message('Hello World')
: creates a new Swift_Message object with the subject "Hello World".setFrom('[email protected]')
: sets the sender address to[email protected]
.setTo('[email protected]')
: sets the recipient address to[email protected]
.addBcc('[email protected]')
: adds the BCC address[email protected]
.setBody('Here is the message itself')
: sets the body of the message to "Here is the message itself".
Helpful links
More of Php Swiftmailer
- How to log emails sent with Swiftmailer?
- How to use SMTP with Swiftmailer?
- How to configure Swiftmailer for SMTP without authentication?
- Swiftmailer usage example
- How to send emails in UTF8 using Swiftmailer?
- How to set timeout with Swiftmailer?
- How to use Swiftmailer transport?
- How to set the 'from' address in Swiftmailer?
- How to use TLS 1.2 with Swiftmailer?
- How to use Swiftmailer to send RFC 2822 compliant emails?
See more codes...