mail not sending from live server working on localhost - php

I am sending mail from laravel its working fine on localhost but same code is not working on live server following is my mail configuration
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=pranav.bitware#gmail.com
MAIL_PASSWORD=******
MAIL_ENCRYPTION=ssl
i have allowed less secure apps in my account
i don't know why its generating error on live server
on some articles they are setting smtp to sendmail i tried that also but getting same error

Providing the error message you get will help with troubleshooting this issue. Since it works on your localhost, then you should look into the server configuration such as your php and Laravel setup, and firewall settings.

Related

Laravel - unable to send email on production

I'm using ovh cloud server and laravel forge to manage my server, I don't know what happened exactly, I have websites and even wordpress installed , everything was fine and can send email from all websites, nowadays no website send email also no error in the log files, and the email function works fine but no email in inbox or even spam
I've tried changing mail to sendmail, the same issue
please advice me
MAIL_DRIVER=mail
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=noreply#****com
MAIL_PASSWORD=*******
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=noreply#*****.com
MAIL_FROM_NAME=“****”
If your using gmail, delete and create new app password. Here is my config
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=***#gmail.com
MAIL_PASSWORD="*****"
MAIL_ENCRYPTION=tls

Mails are not sending from my laravel project

I am sending emails from my Laravel project. In the localhost it works perfectly but after makes the site live it gives the following error.
The connection could not be established with host smtp.googlemail.com:stream_socket_client(): Peer certificate CN=`whm001.smart1marketing.com' did not match expected CN=`smtp.googlemail.com'
I am using same google configuration settings in which I used in Laravel , I have tried clearing all caches, etc. but no solution
Following is .env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=mymail#gmail.com
MAIL_PASSWORD=my password
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=noreply#smart1leads.com
MAIL_FROM_NAME='LifeLoveAndOtherThings'

Why I'm getting Swift_TransportException: Unable to connect with TLS encryption in Server?

I have migrated to new server from old server. There are quite changes in new server. Old server was using PHP 5.6 and phalcon 3.2 and new server is using PHP 7.3 & phalcon 3.4.4.
In old server email sending is working smoothly but in new server it's throwing the below error:
Swift_TransportException: Unable to connect with TLS encryption
Server Mail configuration in both sites are:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
NOTE: Old site was on http and new site is on https
After 35 hours research and with the help of our great team finally found the solution :)
SMTP restriction was enabled on our server from WHM. After disabling the SMTP restriction the error was gone.
You can find this in WHM by searching SMTP and it will be available under security center. Disable it and this error will be no more.

Laravel stopped sending email (mandrill account)

This code was working fine previously and laravel abruptly stopped sending mail since last week. I tried to send mail using swiftmailer separately with same credentials which is also working fine. I have following credentials on .env file for mail functionality in laravel-
MAIL_DRIVER=mandrill
MAIL_HOST=smtp.mandrillapp.com
MAIL_PORT=465
MAIL_USERNAME=*******
MAIL_PASSWORD=*******
MANDRILL_SECRET=*********
MAIL_ENCRYPTION=ssl
I configured /config/services.php and /config/mail.php files to.
There is no error in Mail::failures().
what could be the possible reason for such problem.
I can send mail with templates using swiftmailer but it's necessary to figure-out the problem to fix such problems with no time in future.

Laravel mail setupSwift_TransportException: Expected response code 250 but got code "", with message ""

There are similar questions asked here before. But that are not helping me around solving the problem. This is my current mail configuration in .env file of my laravel file:
MAIL_DRIVER=smtp
MAIL_HOST=****.prod.sin2.secureserver.net
MAIL_PORT=465
MAIL_USERNAME=****#somedomain.com
MAIL_PASSWORD=*****
MAIL_ENCRYPTION=ssl
I've re verified the mail server and credentials. They are accurate and it establishes a connection while tried with php artisan tinkerfrom command prompt with similar response while using the Mail facade of Laravel.
Please help me with this.
Just in case some had the same problem as me, with SMTP and Gmail configuration, my problem was an incorrect server name configured on nginx. You can test this by echoing $_SERVER['SERVER_NAME'] if you have something like I did: ~^(?.*)$ its going to throw that error.
You need to check you nginx config and test the output of the server name.
Thanks to #jagsler for pointing this in the comments.

Categories