Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.5k views
in Technique[技术] by (71.8m points)

php - SMTP in Laravel 7 godaddy hosting

So i have created an App in Laravel 7 and Deployed it in Godaddy Shared hosting, everything works except for the Mailing.

This is the .env values

MAIL_MAILER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=TLS
[email protected]
MAIL_FROM_NAME="YourName"

and the value in config/mail.php 'default' => env('MAIL_MAILER', 'smtp')

This is working Perfectly in Localhost, but when i deployed to goDaddy shared hosting, this doesnt seems to work. I have tried changing the value to .env value to MAIL_MAILER=sendmail and congif/mail.php to 'default' => env('MAIL_MAILER', 'sendmail')

This doesnt show any error, also displayed to Success Message. but Mail not being sent. What is the Fix ?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It seems that GoDaddy blocks SMTP ports to avoid the usage of third-party SMTP services [1] [2]. In order to send emails, GoDaddy says to use their SMTP relay server, which requires no authentication. So your env would look like:

MAIL_MAILER=smtp
MAIL_HOST=relay-hosting.secureserver.net
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
[email protected]
MAIL_FROM_NAME="YourName"

Emails from shared hosts are highly likely to be blacklisted by most servers.

Your next option would be to use an email API such as Mailgun or Sendgrid (there are other providers too of cause). Both of them have a free plan which has a limited quota so you can try.

Finally, your last resort would be to ditch GoDaddy (I never liked them anyway) and move to another host provider. I suggest DigitalOcean (ask me for referral link to get $25 ??) or AWS.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...