I am trying to send email with Bcc, but I have noticed that SwiftMailer is sending emails twice (one with Bcc and the other without it), and I removed bcc it's working fine without duplicated mails.
mailController.php
class mailController extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from('[email protected]', 'test')
->view('portal.confirmation')
->subject('test Email')
->bcc('[email protected]','wahdan');
}
}
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
Update
This issue happen only in local environment ,but in production it's working perfect without any duplicated emails.
If you BCC an email and send it through mailtrap.io, you will receive two copies of the email in your mailbox. If there are two BCCs, you will receive three copies, etc. The emails will look identical (including the "To:").
This behavior is specific to mailtrap.io, not Laravel (i.e., it is not on the sending side).
If the number of duplicate emails is the same as the number of BCCs plus the original, I think you can be confident that is the reason.
This answer assumes that you are using mailtrap.io as your SMTP server locally, but not in production.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With