如果结合laravel通知& amp;邮件,为什么发件人的电子邮件中没有密件抄送Laravel可以邮寄吗? [英] Why is there no bcc in sender's email if combine laravel notification & Laravel mailable?

查看:87
本文介绍了如果结合laravel通知& amp;邮件,为什么发件人的电子邮件中没有密件抄送Laravel可以邮寄吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Laravel 5.3

I use Laravel 5.3

我的控制器是这样的:

auth()->user()->notify(new ConfirmOrder($invoice));

我的通知是这样的:

<?php
...
class ConfirmOrder extends Notification implements ShouldQueue, ShouldBroadcast
{
    use Queueable;
    private $data;
    public function __construct($data)
    {
        $this->data = $data;
    }
    public function via($notifiable)
    {
        return ['mail'];
    }
    public function toMail($notifiable)
    {
        $mail_myshop = explode(',', config('app.mail_myshop'));
        return (new ConfirmOrderMail($this->data, $notifiable))
            ->to($notifiable->routeNotificationFor('mail'))
            ->bcc($mail_myshop)
            ->subject('Thanks');
    }
}

我的可寄信是这样的:

<?php
...
class ConfirmOrderMail extends Mailable
{
    use Queueable, SerializesModels;
    public $data;
    public $user;
    public function __construct($data, $user)
    {
        $this->data = $data;
        $this->user = $user;
    }
    public function build()
    {
        return $this->view('vendor.notifications.mail.email-confirm-order',['data'=>$this->data, 'name' => $this->user->name]);
    }
}

我将通知和可邮寄结合在一起,因为laravel 5.3不支持密件抄送

I combine notification and mailable, because laravel 5.3 not support bcc

它有效,但是有一个缺点.电子邮件发件人上没有密件抄送.例如,有3封密件抄送电子邮件.它应该显示在发件人的电子邮件中(如果我单击gmail上的已发送邮件,然后单击详细信息,是否应该存在电子邮件密件抄送.但是没有电子邮件密件抄送)

It works, but there is one shortcoming. There is no bcc on the email sender. For example, there are 3 emails of bcc. It should appear in the sender's email (If I click sent mail on the gmail and click the detail, Should there exist email bcc. But there is no email bcc)

我在这样的环境中设置发件人电子邮件:

I setting my sender email in env like this :

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=****@gmail.com
MAIL_PASSWORD=****
MAIL_ENCRYPTION=tls

如何在发件人电子邮件(已发送邮件)上显示密件抄送?

How can I display bcc on the sender email(on the sent mail)?

更新:

我将添加我的问题的详细信息

I will add details of my problem

如果我通过gmail这样发送邮件:

然后我检查电子邮件发件人的gmail上的已发送邮件菜单,结果如下:

Then I check on sent mail menu on gmail from email sender, the result like this :

好像是密件抄送电子邮件

There looks like bcc email

如果我使用上面的代码从Laravel发送邮件,则结果为:

我检查电子邮件发件人的已发送邮件"菜单,结果如下:

I check on the sent mail menu from email sender, the result like this :

好像没有电子邮件密件抄送

There looks like no email bcc

我想要的是:我想在laravel的发件人电子邮件上显示密件抄送电子邮件

What I want is: I want to display bcc email on the sender's email on laravel

我该怎么办?

推荐答案

这不可能.

Laravel对SMTP邮件使用 SwiftMailer .当您在密件抄送"字段中发送包含地址列表的电子邮件时,SwiftMailer实际上会分解该列表,并向每个地址发送一封单独​​的电子邮件.

Laravel uses SwiftMailer for SMTP mail. When you send an email with a list of addresses in the BCC field, SwiftMailer actually breaks up that list and sends each address an individual email.

因此,SwiftMailer不会发送一封邮件,邮件标题为 BCC:test1 @ gmail.com,test2 @ gmail.com,test3 @ gmail.com ,而是会发送三封邮件,邮件标题为<分别是code> BCC:test1@gmail.com , BCC:test2@gmail.com BCC:test3@gmail.com .

So, instead of sending one email with the header BCC: test1@gmail.com, test2@gmail.com, test3@gmail.com, SwiftMailer will send three separate emails with the headers BCC: test1@gmail.com, BCC: test2@gmail.com, and BCC: test3@gmail.com, respectively.

由于您在Gmail中收到的电子邮件的 BCC 标头中没有地址列表,因此无法向您显示该列表.

Since the email you receive in Gmail does not have a list of addresses in the BCC header, it cannot show you the list.

现在,我说这是不可能的,但是从技术上,如果需要,您可以派发SwiftMailer存储库,更新代码以不将密件抄送收件人拆分为单独的电子邮件,然后弄清楚如何让Laravel使用您自定义的SwiftMailer版本,但是我非常怀疑这样做是否值得.

Now, I said it's not possible, but technically, if you wanted, you could fork the SwiftMailer repository, update the code to not split the BCC recipients into separate emails, and then figure out how to get Laravel to use your customized version of SwiftMailer, but I highly doubt that would be worth the effort.

这篇关于如果结合laravel通知&amp; amp;邮件,为什么发件人的电子邮件中没有密件抄送Laravel可以邮寄吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆