Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

RicLeP's avatar
Level 6

Laravel 11 Mail sending to only first recipient in a loop / CC adding only X-CC header

This is using Laravel 11. I have two issues, happy to have either fixed as they’d both resolve the problem!

I’ve a loop of email addresses to send a Mail to but the first recipient is used for every message - so three addresses = three emails all to the first person.

I am using the Postmark driver and also tried Mailpit in dev.

$recipients = array_merge([config('mail.to.address')], explode(',', config('mail.cc.address')));

foreach ($recipients as $recipient) {
    Mail::to($recipient)
        ->send(
            new ContactForm($request->except(['_token', '_slug']), $formName)
        );
}

This is as shown in the docs. My Mailable doesn’t do anything to set addresses.

If I write each Mail individually and specify the address it always uses the first one config('mail.to.address').

If I dump the recipients in Mailable buildRecipients(), I see all the addresses I want to send to.

I also tried to CC in the other emails (instead of the loop) but when I do this it adds a X-CC header to the email message, not the CC header.

0 likes
0 replies

Please or to participate in this conversation.