Alfresco 5.1 Configure Outbound email with Office 365

Hello,

I have reviewed a variety of posts regarding configuring Outbound mail to use Office 365 with prior versions of Alfresco, however I have tried the settings and am getting an error in Alfresco 5.1.

My settings alfresco-global.properties:
mail.host=smtp.office365.com
mail.port=587
mail.protocol=smtps
mail.from.default=test@mydomain.com
mail.username=test@mydomain.com
mail.password=mypassword
mail.encoding=UTF-8
mail.smtps.starttls.enable=true
mail.smtps.auth=true

I can telnet to smtp.office365.com 587 successfully, so I know the port is not blocked.

The error in the alfresco log is:
2016-05-03 12:18:37,864 ERROR [org.alfresco.repo.action.executer.MailActionExecuter] [ajp-apr-8009-exec-5] Failed to send email to someuser@mydomain.com : org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: smtp.office365.com, port: 587;
nested exception is:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?. Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: smtp.office365.com, port: 587;
nested exception is:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?; message exceptions (1) are:
Failed message 1: javax.mail.MessagingException: Could not connect to SMTP host: smtp.office365.com, port: 587;
nested exception is:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

What else can I look at?

Regards,
Ron

Hi,

That port is for TLS and not in SSL. It seems it is required to add the following Java property to your installdir/apache-tomcat/bin/setenv.sh file, could you check if it works?

-Dmail.smtp.starttls.enable=true

Thanks!

Hi @marcos.

I tried that setting and it did not make any difference. Based on your comment about the port not being SSL, I modified the settings to change from smtps to smtp.

My settings in alfresco-global.properties:
mail.host=smtp.office365.com
mail.port=587
mail.protocol=smtp
mail.from.default=test@mydomain.com
mail.username=test@mydomain.com
mail.password=mypassword
mail.encoding=UTF-8
mail.smtp.starttls.enable=true
mail.smtp.auth=true

I then received a different error in the log: Client does not have permissions to send as this sender

After doing some searching on the new error message I found one additional setting that was needed:

mail.from.enabled=false

This setting is needed for any email server that does not allow Forwarding, like Office 365 mail. Alfresco now sends emails successfully using Office 365 email.

Regards,
Ron

Exchange Online Protection filters inbound and outbound email messages, checking for diverse threats. Filtering of inbound emails is done by using rules and policies based on the sender’s reputation, IP addresses, email addresses and domain address, and keywords and complex Microsoft analysis algorithms. Email messages that are classified as dangerous are rejected and deleted.

Filtering outbound emails is needed to avoid situations in which a user at a company is sending spam to others. If you do not filter such messages, your domain or IP address will be added to a blacklist by other organizations. Being blacklisted as a spammer is damaging and can cause problems when delivering emails sent by users from your organization. It is much easier to configure outbound email filtering than try to exclude your domain from a blacklist. Another case for using outbound filtering is when somebody hacks a user account and uses that compromised account to send spam.