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 log emails sent with Swiftmailer?
- How to send emails in UTF8 using Swiftmailer?
- How to use TLS 1.2 with Swiftmailer?
- How to set timeout with Swiftmailer?
- How to use Swiftmailer with Symfony?
- How to set the reply to address in Swiftmailer?
- How to mock SwiftMailer?
- How to configure Swiftmailer logger?
- How to get the error message in Swiftmailer?
- How to set the 'from' address in Swiftmailer?
See more codes...