Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel mail bcc

Tags:

I am using the default Laravel Mail class to send emails.

I am trying to add bcc to myself, but when I add a bcc the email is not send at all.
Here is my code:

Mail::send(
    'emails.order.order',
    array(
        'dateTime'  => $dateTime,
        'items'     => $items
    ),
    function($message) use ($toEmail, $toName) {
        $message->from('[email protected]', 'My Company');

        $message->to($toEmail, $toName);
        $message->bcc('[email protected]');

        $message->subject('New order');
    }
);
like image 731
Ivan Dokov Avatar asked Nov 06 '14 07:11

Ivan Dokov


2 Answers

I have found the problem.
I didn't use the correct parameters for $message->bcc('[email protected]');

I had to write email AND name: $message->bcc('[email protected]', 'My Name');
The same way as I use $message->to($toEmail, $toName);

like image 163
Ivan Dokov Avatar answered Sep 19 '22 04:09

Ivan Dokov


As Ivan Dokov said, you need to pass the email and name to the bcc function. You could also shorten your code by doing this

  function($message) use ($toEmail, $toName) {
        $message->from('[email protected]', 'My Company')
                ->to($toEmail, $toName)
                ->bcc('[email protected]','My bcc Name')
                ->subject('New order');
    }
like image 42
Sr.PEDRO Avatar answered Sep 22 '22 04:09

Sr.PEDRO