通过laravel从地址发送电子邮件 [英] Send email from address with laravel

查看:52
本文介绍了通过laravel从地址发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将我的mail.php配置文件配置为使用gmail帐户发送电子邮件.一切看起来都很不错,但是当我尝试从另一个帐户(而不是mail.php配置文件中使用的地址)发送电子邮件时,我从配置文件上设置的地址中收到了一封电子邮件.

I have configured my mail.php config file to send emails using the gmail account. Everything looks great, but when I try to send email from another account (not the address used in the mail.php config file) I get an email from the address set on the configuration file.

Mail::send('emails.contact_mail', array(
            'email' => $fromEmail,
            'name' => $user,
            'subject' => $subject,
            'message' => $message_content,
                ), function($message)use ($fromEmail,$user,$subject) {

                    $message->to('s111@gmail.com');
                    $message->from('test@gmail.com', $user);
                    $message->subject($subject);

                });

似乎来自 $ message-> 的行不通.我在 s111@gmail.com 上收到的电子邮件来自 mail.php 文件中设置的地址,而不是来自 test@gmail.com .有什么解决办法吗?如何更改来自地址?

It seems like the $message->from doesn't work. I get on the s111@gmail.com an email from the address set in mail.php file and not from test@gmail.com. Is there any solution? How to change the from address?

推荐答案

您仍将使用配置文件中设置的SMTP服务器.从理论上讲,可以设置另一个发件人"标头,但是除非您设置了已添加到Google帐户中的地址,否则GMail SMTP会忽略它.

You will still use the SMTP servers set in your config file. Setting another 'from' header is theoretically possible, but the GMail SMTP will ignore it unless you set an address that has been added to your Google account.

解决方案:要么不使用其他发件人"地址,要么将该地址添加到您的Google帐户.

Solution: either don't use another 'from' address, or add that address to your Google account.

这篇关于通过laravel从地址发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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