在 GoDaddy 服务器上发送电子邮件时出错:Laravel 5.1
我在 Laravel 5.1 中使用登录系统的内置模板
当我在本地主机上使用忘记密码时,一切正常.以下是我在 .env 文件中的密钥
MAIL_DRIVER=smtpMAIL_HOST=smtp.gmail.comMAIL_PORT=587MAIL_USERNAME=用户名MAIL_PASSWORD=密码MAIL_ENCRYPTION=tls
当我在 Godaddy 服务器上尝试同样的事情时,我面临以下错误.
<块引用>StreamBuffer.php 第 265 行中的 Swift_TransportException:连接无法与主机 smtp.gmail.com 建立 [连接被拒绝
111]
解决方案您的 env 文件必须如下所示
MAIL_DRIVER=smtpMAIL_HOST=本地主机MAIL_PORT=465MAIL_USERNAME=邮件密码=MAIL_ENCRYPTION=ssl
在您的 config/mail.php
中,from 值应如下所示...
'from' =>['地址' =>'pankaj@YourDomainName.com', 'name' =>'发件者姓名'],
你的域名来自于什么?或者您可以说,如何在 GoDaddy 中创建电子邮件帐户?
<块引用>- 登录您的 GoDaddy 帐户
- 转到您的托管帐户.
- 点击管理
- 在电子邮件类别下,请点击帐户
- 如果没有电子邮件帐户,请创建一个帐户.
就是这样.
假设您有像 Pankaj@yourdomainname.com 这样的电子邮件地址
现在,将此电子邮件地址放在 config/mail.php 的 from 字段中.就是这样.
这将 100% 解决问题
I am using inbuilt template of Login System in Laravel 5.1
When I use Forgot Password on localhost, everything works. Below are my keys in .env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=userid
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
When I try the same thing on Godaddy server, I am facing the below error.
Swift_TransportException in StreamBuffer.php line 265: Connection could not be established with host smtp.gmail.com [Connection refused
111]
解决方案
Your env file must be like below
MAIL_DRIVER=smtp
MAIL_HOST=localhost
MAIL_PORT=465
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=ssl
In your config/mail.php
, the from value should be like below...
'from' => ['address' => 'pankaj@YourDomainName.com', 'name' => 'Sender Name'],
What's your domain Name in from ? or you can say, How to create Email account in GoDaddy ?
- Login in your GoDaddy Account
- Go to your Hosting Account.
- Click Manage
- Under Email category, Please click Accounts
- Create an account if there is no email account.
and that's it.
So let's say you have email address like Pankaj@yourdomainname.com
Now, put this email address in config/mail.php for from field. That's it.
This will 100% fix the issue
相关文章