Office365 smtp rejected

Hello everyone,

I am having issues with SMTP settings to office365. I have researched on the forum and phpmailer knowledgebase but couldn’t find a way to fix it.

Just some ways I have tried…

In the settings, I have tried TLS and SSL. Tried port 587 with TLS and other combinations with no luck.
Replaced class.phpmailer.php and class.smtp.php
Changed phpmailer logging to error report to see the connection status.
Tried using ‘Microsoft Exchange’ and ‘Other’ to put in the details.
All field (server addr, username, password, port, SSL/TLS) were being typed in every single try
All credentials are 100% correct as in inbound email setting, it works.

Some info…

Server is using TLS v1.2
Tried to use CPanel local mail account, it works, sends out email.

In log, I can see connection opened, but server returned 220-We do not authorize the use of this system to transport unsolicited, and/or bulk e-mail.

Would anyone please give me a hint on how to get it work?

Thanks and regards,
Shaun

Make sure the mail server is: smtp.office365.com
Port is: 587
the from and username email is the same
and is TLS

And you have granted access from the exchange to allow this > you can do this in the exchange management console

According to GoDaddy, they block the ports on a shared environment(all of them do in fact). So for this to work it has to be on a non shared environment.

I was able to get my cpanel out to work using port 25 and my domain(example.com) as the server. NO TLS or SSL. The out works but I found that some of my emails end up in spam folders.

This is unfortunately a big problem and hopefully the next version will have a work around for this. The only choice is to upgrade the hosting (about $20-40/month more) if you include support.

This is going to apply to all of the shared hosting services.

I could never find an “Exchange Management Console”

As a reference for those who are experiencing this issue with Office365 I’ll share the solution what worked for me.
Background: I found this issue occurs when you are hosting your CRM o domain different to the one you have setup on your Office365. (That’s my case at least).

To solve it you either add your CRM domain to your Office365.
If for some reason you are not allow to do it, the workaround is to modify the sugar library that creates the emails on SuiteCRM (Thanks to @R3xMan). To do so you need to modify file \include\SugarPHPmailer.php from


...
       $this->isHTML(false);  // default to plain-text email
        
	$this->Hostname = $sugar_config['host_name'];
        $this->WordWrap = 996;
        // cn: gmail fix
        $this->protocol = ($this->oe->mail_smtpssl == 1) ? 'ssl://' : $this->protocol;
        $this->SMTPAutoTLS = false;
...

To:


...
       $this->isHTML(false);  // default to plain-text email
        
	$this->Hostname = $sugar_config; // TAKE A LOOK INTO THIS LINE
        $this->WordWrap = 996;
        // cn: gmail fix
        $this->protocol = ($this->oe->mail_smtpssl == 1) ? 'ssl://' : $this->protocol;
        $this->SMTPAutoTLS = false;
...

You can check the original post here:
https://suitecrm.com/suitecrm/forum/suitecrm-7-0-discussion/21720-smtp-error-501-5-5-4-invalid-domain-name-7-11

Thanks,
AlxGr