Connecting to Office 365 not working

I'm trying to setup the mail server but it will not connect to my Office 365 account (connection refused):

SMTP Server: smtp.office365.com
SMTP Port: 587
ESMTP Username: [My Office 365 Email Address (username@domain.com)]
ESMTP Password: [My Office 365 Password]
Site 'From' Name: [My Name]
Site 'From' Address: [My Office 365 Email Address]

Has anyone successfully connect their Office 365 email account?

Can you see what is showing up in your event.log when Plone tries to send an email?

I somehow nuked my test site. The fact I'm not sure how or why it happened is very troubling. I guess I'll have to be way more careful with Plone than I was with Wordpress which has survived 2 years of noobie admin abuse (and countless marginal plugins).

Anyway, I will start again and get back to you with the event.log entries.

By the way, is there any difference in using the Plone app installer (Bitnami) on Google Cloud vs installing it from CLI (like I did on Digitalocean)? Are both installations "correct/supported"?

Ok, I used Google Cloud to fire up an instance of Plone. Here's what happens when I try to setup email:

2017-01-31T06:05:14 ERROR Plone Unable to send test e-mail.
Traceback (most recent call last):
File "/opt/bitnami/apps/plone/buildout-cache/eggs/Products.CMFPlone-5.0.6rc1-py2.7.egg/Products/CMFPlone/control$
immediate=True)
File "/opt/bitnami/apps/plone/buildout-cache/eggs/Products.MailHost-2.13.2-py2.7.egg/Products/MailHost/MailHost.$
self._send(mfrom, mto, messageText, immediate)
File "/opt/bitnami/apps/plone/buildout-cache/eggs/Products.MailHost-2.13.2-py2.7.egg/Products/MailHost/MailHost.$
self._makeMailer().send(mfrom, mto, messageText)
File "/opt/bitnami/apps/plone/buildout-cache/eggs/Products.CMFPlone-5.0.6rc1-py2.7.egg/Products/CMFPlone/patches$
return func(*args, **kwargs)
File "/opt/bitnami/apps/plone/buildout-cache/eggs/zope.sendmail-3.7.5-py2.7.egg/zope/sendmail/mailer.py", line 4$
connection = self.smtp(self.hostname, str(self.port))
File "/opt/bitnami/python/lib/python2.7/smtplib.py", line 256, in init
(code, msg) = self.connect(host, port)
File "/opt/bitnami/python/lib/python2.7/smtplib.py", line 316, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/opt/bitnami/python/lib/python2.7/smtplib.py", line 291, in _get_socket
return socket.create_connection((host, port), timeout)
File "/opt/bitnami/python/lib/python2.7/socket.py", line 575, in create_connection
raise err
error: [Errno 101] Network is unreachable

Looks more like a firewall or networking problem than a Plone issue. Is the machine allowed to do outgoing SMTP?

I don't know. I Googled around for a while and read a few Linux firewall articles. I ran the following command but don't see any useful info:

~$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Is it the wrong command? Plone is running on Debian 8

More Googling. I ran the following 2 commands:

sudo iptables -A OUTPUT -p tcp --sport 587 -j ACCEPT
iptables -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

Still no dice.

Yeah it's your firewall. Sorry, you'll have to dig around for Google Cloud specific instructions.

[quote="tkimnguyen, post:8, topic:3370"]
Yeah it's your firewall.
[/quote]Thanks for clarifying. I will deal with this later since it's not important for my test site and also because I'll likely be hosting my production site elsewhere.

1 Like

I just wanted to update this just in case someone else came across the same issue. Anyway, from the Google Cloud website:

Using standard email ports

Google Compute Engine does not allow outbound connections on ports 25, 465, and 587. By default, these outbound SMTP ports are blocked because of the large amount of abuse these ports are susceptible to. In addition, having a trusted third-party provider such as SendGrid, Mailgun, or Mailjet relieves Compute Engine and you from maintaining IP reputation with your receivers.

1 Like

So the problem is that you can't use outgoing ports of smtp. Thanks Google. Now like a good customer I sat and thought. How can I bypass that and do what they don't really want me to do.

So the solution I found was setting up a Microsoft Flow to receive POST request over https andfrom that request to send an email.
I also added a simple auth to make sure no one sniffed my url and started using it himself. So I added a condition to make sure the field key in the post's body was equal to what I defined.
That was the request going from Google in on port 443. Problem solved. Now no reputation to Google's IP is affected.