Reputation: 45
I'm at my wits end. We were having issues with sending email on a GoDaddy hosting, mostly that it was too unreliable (sometimes it worked flawlessly, sometimes I have to send several emails for one to go through, long queues, and so on. This is not the first time I've had these issues with them, by the way). So, I called them and their recommended solution was to set up an office 365 account and use that instead. I passed that information to my client, and he did it (albeit not via Godaddy's office 365 product, but directly with Microsoft, which certainly helps explain the difficulty), but I still cannot connect. I started to research this issue, but at this point I can say I am just lost. Here's everything I tried / learned, as well as the connections I'm trying.
My PHP setup is laravel 5.2, sending email via swiftmailer. The connection data is on an .env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
And a sample php script sending emails
$logger = new \Swift_Plugins_Loggers_EchoLogger();
Mail::getSwiftMailer()->registerPlugin(new \Swift_Plugins_LoggerPlugin($logger));
$master_email = "[email protected]";
Mail::send('emails.contact_us', $data, function ($message) use ($master_email, $request) {
$message->from("[email protected]");
$message->to($master_email)->subject('Subject');
});
And it fails with the message
++ Starting Swift_SmtpTransport !! Connection could not be established with host smtp.office365.com [Connection refused #111] (code: 0)
There are plenty of comments saying that GoDaddy simply blocks outgoing smtp connections and forces you to use their relay service. However, all sources mentioning this seem to be outdated (2014 and earlier), not to mention I'm trying the setup that their support suggested on phone.
I've already did everything instructed on this microsoft article. On my office 365 admin account I can validate DNS to check if everything is okay, it says so. Microsoft support also says everything is correct. Domains are set up as "authoritative"
I've also tried setting up a connector and trying to connect to mydomain-com.mail.protection.outlook.com, fails with same error, so for now I've deleted that connector
I've called GoDaddy support to see if it was something like a firewall blocking my connection, and they said that's not it. They recommended deleting my workspace email account, I did so, still fails after that.
And so, I'm lost. I need this to work somehow, sending emails via microsoft's smtp server (and not godaddy's) specially because my client already set up his office 365 account and paid for it, so...yeah. Am I missing some configuration beyond the DNS changes? Should I connect to some other smtp server? Change hosts? Am I missing some parameter on my PHP scripts?
This seems to be fairly common issue, but it is surprisingly hard to find some definite answer. Hopefully my case will help others attempting something similar.
Upvotes: 1
Views: 2264
Reputation: 440
I had with the same problem in Laravel OctoberCMS on Godaddy. The only config that worked for me is:
MAIL_DRIVER=sendmail
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
I hope this helps
Upvotes: 1