'Connection could not be established with host smtp.office365.com :stream_socket_client(): php_network_getaddresses
I'm getting this error when sending an email via Office 365 from a Laravel system. But the peculiarity is that it is random. It is not a mail configuration problem. Sometimes it works, sometimes it gives the error. I think Office 365 is doing a lock. But the error message confuse me. Has it happened to someone? Thanks!
Connection could not be established with host smtp.office365.com :stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known site:stackoverflow.com
Solution 1:[1]
if you are sure that you configure the mail correctly
MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME= //your username
MAIL_PASSWORD= //your password
MAIL_ENCRYPTION=tls
according to this issue discussions, it seems that it may related to WHM/Cpanel Users-- there is a tweak setting that may be tripping you up and redirecting outgoing email connections to localhost (which is then rejecting your connection).
https://features.cpanel.net/topic/change-fka-smtp-tweak-behavior-to-encourage-correct-user-behavior
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Omar Tammam |
