Laravel: office365 connection timeout on aws - laravel

Don't know why smtp.office365.com stopped work suddenly on production but works on dev.
Let's see some code:
.env configuration
MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=25
MAIL_USERNAME=nao_responda#primorossi.com
MAIL_PASSWORD=********
MAIL_ENCRYPTION=tls
MAIL_SMTPAuth=true
MAIL_FROM_NAME="Grupo Primo Rossi"
MAIL_FROM_ADDRESS=nao_responda#primorossi.com
The Laravel error page:
Swift_TransportException
Connection could not be established with host smtp.office365.com [Connection timed out #110]
The weirdest thing is that this configuration worked ok when I published and stopped working for no reason.
Anyone?
Thanks in advance!

SOLVED!
Chenged the port from 25 to 587
MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=nao_responda#primorossi.com
MAIL_PASSWORD=********
MAIL_ENCRYPTION=tls
MAIL_SMTPAuth=true
MAIL_FROM_NAME="Grupo Primo Rossi"
MAIL_FROM_ADDRESS=nao_responda#primorossi.com
Now it is working good!

Related

Swift_TransportException Connection to ssl://mail.diamonexchange.com:465 Timed Out

Of recent my laravel app keeps timing out on mail cpanel connection
MAIL_MAILER=smtp
MAIL_HOST=mail.******.com
MAIL_PORT=465
MAIL_USERNAME=info#*****.com
MAIL_PASSWORD=**********
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=info#*******.com
MAIL_FROM_NAME="${APP_NAME}"
Here is screenshot of the output

stream_socket_client(): unable to connect to tcp://smtp.sendgrid.net:587

I send Emails using Sendgrid Service. In my local environment, it's working perfectly. but Production Server Environment I got the following error.
Swift_TransportException GET /rpc/insurances/sendregisemail/a9e13e20-2910-11ea-88e2-534f2fd3cc6a .
Connection could not be established with host smtp.sendgrid.net :stream_socket_client(): unable to connect to tcp://smtp.sendgrid.net:587 (Connection refused)
This solved my problem
MAIL_DRIVER=smtp or MAIL_MAILER=smtp for Laravel >= 7
MAIL_PORT=587
To
MAIL_DRIVER=sendmail or MAIL_MAILER=sendmail for Laravel >= 7
MAIL_PORT=587

Laravel - Connection could not be established with host smtp.googlemail.com :stream_socket_client(): unable to connect

I'm trying to send an email from Gmail using Laravel from localhost. I'm getting this error:
Connection could not be established with host smtp.googlemail.com
:stream_socket_client(): unable to connect to ssl://smtp.googlemail.com:465
(A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because
connected host has failed to respond.)
My .env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=myusername#gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=ssl
What is the error? Do i need to change some setting in the server or firewall?
In .env file try the following code:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
mail_username=myusername#gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
In Localhost, edit .env file and paste the following code:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=secret#gmail.com
MAIL_PASSWORD=secret
MAIL_ENCRYPTION=tls
In Server, edit .env file and paste the following code:
Step 1:
MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=secret#gmail.com
MAIL_PASSWORD=secret
MAIL_ENCRYPTION=tls
Step 2:
In config/mail.php change the following code:
'default' => env('MAIL_MAILER', 'smtp'),
TO
'default' => env('MAIL_MAILER', 'sendmail'),
Note: Make sure to enable "Less secure app access" in Gmail account.
first of all check your network connectivity and firewall services that are in use.
use your private network for this.
don't use public network.
public network deny the connection.

Swift_TransportException Connection could not be established with host smtp.gmail.com [Network is unreachable #101]

Some months ago, I used gmail setting in my .env file,
MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myEmail#gmail.com
MAIL_PASSWORD=myPassword
MAIL_ENCRYPTION=tls
It was working perfectly fine. But suddenly it stopped working.
Now, it is showing an error, which is:
ErrorException (E_WARNING) proc_open() has been disabled for security reasons
What's going on?? I have tried all the methods found on internet but didn't worked.
Did Gmail got any new security system?
I have tried changing,
MAIL_DRIVER=sendmail to MAIL_DRIVER=smtp
But getting below error,
Swift_TransportException Connection could not be established with host smtp.gmail.com [Network is unreachable #101]

Error: connection could not be established with host smtp.gmail.com #0 - LARAVEL

I am trying send emails but I am getting the error below:
"connection could not be established with host smtp.gmail.com #0".
I made test with different ports (465, 578), with SSL and TLS and the last with the mail account and it is working.
I think that the problem is on XAMPP.
What am I doing wrong and how can I resolve it?
Try using:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_ENCRYPTION=tls
MAIL_USERNAME=y*****4#gmail.com
MAIL_PASSWORD=a*****
Hope, it works for you.

Resources