laravel SMTP邮件 [英] laravel SMTP mail

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

问题描述

我正在尝试使用Google邮件上的smpt发送邮件 我的.env文件是

I am trying to send the mail using smpt on google mail my .env file is

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=MYEmailAddress
MAIL_PASSWORD=MyPassword
MAIL_ENCRYPTION=tls

,服务器代码为

try {
        Mail::send([], [], function ($message) use ($completeView,$emailAdress) {
            $message->to($emailAdress, $emailAdress)->subject("Property List");
            $message->from("Myemail", "info")->setBody($completeView, 'text/html');
        });
    } catch (\Exception $e) {
        return array([$e->getMessage(),"Myemail"]);
    }

我还启用了Gmail中的不太安全的应用访问权限 我从服务器得到的响应是

I also enable the Less secure app access in gmail and the response I get from the server is

预期的响应代码为250,但代码为"530",消息为"530 5.7.1,需要身份验证"

Expected response code 250 but got code \"530\", with message \"530 5.7.1 Authentication required

推荐答案

  1. (如果您使用的是Gmail地址发送邮件).那么您需要使用不太安全的应用.

  1. if you are using gmail address to sent mail. then you need to on less secure app.

转到 https://myaccount.google.com/lesssecureapps

然后将其打开.

,并且还使用php artisan config:clear

and also use php artisan config:clear

有时,当您尝试通过某些代码发送电子邮件时,Google会阻止.在这种情况下,您会收到一封警报邮件.单击该邮件(检查活动),然后标记为是(您识别此活动吗?)

sometimes google blocks when you try to send email through some code. In that case you got a alert mail. click on that mail(Check Activity) and mark as yes (Do you recognize this activity?)

或者您可以尝试MAIL_DRIVER = sendmail并使用php artisan config:clear

Or you can try MAIL_DRIVER=sendmail and also use php artisan config:clear

这篇关于laravel SMTP邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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