Ask Your Question
1

Is it possible to send emails using Laravel without using mailables, but are cc/bcc recipients exempted from this working method?

asked 2022-12-25 11:00:00 +0000

bukephalos gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-10-08 01:00:00 +0000

djk gravatar image

Yes, it is possible to send emails using Laravel without using mailables. You can use the Mail::raw() method to send a raw email message. However, cc/bcc recipients are not exempted from this working method. You can still include cc/bcc recipients in your raw email message by adding them to the headers of the message. Here's an example:

use Illuminate\Support\Facades\Mail;

Mail::raw('This is the email body', function ($message) {
    $message->to('johndoe@example.com');
    $message->cc('janedoe@example.com');
    $message->bcc('someone@example.com');
    $message->subject('Test Email');
    $message->getHeaders()->addTextHeader('Cc', 'janedoe@example.com');
    $message->getHeaders()->addTextHeader('Bcc', 'someone@example.com');
});

In the example above, the cc() and bcc() methods are included for readability, but they are not necessary since the addresses are already added to the headers.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-12-25 11:00:00 +0000

Seen: 7 times

Last updated: Oct 08 '22