php-swiftmailerHow to set multiple BCC addresses using Swiftmailer?
Swiftmailer can be used to set multiple BCC addresses in an email. To do this, the addBcc()
method can be used. The following example code shows how to set multiple BCC addresses using Swiftmailer:
$message = (new \Swift_Message('Hello World'))
->setFrom('[email protected]')
->setTo('[email protected]')
->addBcc('[email protected]')
->addBcc('[email protected]');
The output of the above code will be an email sent from [email protected]
to [email protected]
with [email protected]
and [email protected]
as BCC recipients.
Code explanation
$message
: This is a variable that stores the message object.\Swift_Message('Hello World')
: This creates a new Swift_Message object with the subject line "Hello World".setFrom('[email protected]')
: This sets the sender of the email to[email protected]
.setTo('[email protected]')
: This sets the recipient of the email to[email protected]
.addBcc('[email protected]')
: This adds[email protected]
as a BCC recipient.addBcc('[email protected]')
: This adds[email protected]
as a BCC recipient.
Helpful links
More of Php Swiftmailer
- How to set timeout with Swiftmailer?
- How to use SMTP with Swiftmailer?
- How to use TLS 1.2 with Swiftmailer?
- How to get the response code when using Swiftmailer?
- How to use Swiftmailer to send RFC 2822 compliant emails?
- How to configure Swiftmailer for Postfix?
- How to send emails in UTF8 using Swiftmailer?
- How to send emails to multiple recipients with Swiftmailer?
- How to set the port for Swiftmailer?
- How to enable TLS with Swiftmailer?
See more codes...