Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Universal To using CC and BCC, ends up with 3 mails #20075

Closed
empresarrollo opened this issue Jul 14, 2017 · 4 comments
Closed

Universal To using CC and BCC, ends up with 3 mails #20075

empresarrollo opened this issue Jul 14, 2017 · 4 comments

Comments

@empresarrollo
Copy link

  • Laravel Version: 5.4.26
  • PHP Version: 7.0.2
  • Database Driver & Version: MySQL 5.7.28

Description:

When using "Universal TO" in config/mail.php:

    'to' => [
        'address' => '[email protected]',
        'name' => 'Testing Dude'
    ],

and using MAIL_DRIVER=log, or smtp, or sparkpost, Laravel put your "universal to" also on the CC and BCC fields of the email. Then you end up with 3 copies of the same mail.

Steps To Reproduce:

  1. php artisan make:notification InvoicePaid --markdown=mail.invoice.paid
  2. create view for mail.invoice.paid
  3. modifiy toMail() in InvoicePaid: return (new MailMessage)->subject('Invoice Paid')->markdown('mail.invoice.paid');
  4. $user = App\User->create(...........)
  5. $user->notify((new InvoicePaid($invoice));

using MAIL_DRIVER=log you would see the folowing in laravel.log:

[2017-07-14 17:31:12] local.DEBUG: Message-ID: <[email protected]>
Date: Fri, 14 Jul 2017 17:31:12 -0300
Subject: Invoice Paid
From: MyApp <[email protected]>
To: Testing Dude <[email protected]>
Cc: Testing Dude <[email protected]>
Bcc: Testing Dude <[email protected]>
MIME-Version: 1.0
Content-Type: multipart/alternative;

with log everything is OK, but if you use smtp or sparkpost to test the emails you and up with triple the mails.

@Douglasdc3
Copy link
Contributor

Douglasdc3 commented Jul 17, 2017

Setting a global to in your config will override any other mail address already set before. According to the code you should only use this for local development.

        // If a global "to" address has been set, we will set that address on the mail
        // message. This is primarily useful during local development in which each
        // message should be delivered into a single mail address for inspection.
        if (isset($this->to['address'])) {
            $this->setGlobalTo($message);
        }

@devcircus
Copy link
Contributor

#16705

@empresarrollo
Copy link
Author

Setting a global to in your config will override any other mail address already set before. According to the code you should only use this for local development.

Yeah, I'm using for development, and testing that sparkpost works ok. But setting to also put that address in CC and BCC (although I'm not using that).

@themsaid
Copy link
Member

Check #16705

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants