Office365 SMTP: "unable to establish SMTP connection"

550 views
Skip to first unread message

Alexander Farley

unread,
May 24, 2018, 7:57:49 PM5/24/18
to
Background:
Just set up Bugzilla 5.0.4 on Ubuntu 14.04.5 LTS VM hosted inside Windows Server. SMTP email from Bugzilla is working using Gmail; I've sent new-account notifications successfully, and users have created new accounts.

My employer would prefer for new-account notifications (and Bugzilla email in general) to come from our company email addresses on Outlook/Office365. I have been unable to sent email using Office365 so far.

I've read various posts on this topic but none have led to a resolution.

Various parameters I've tried:

********** smtpserver **********

smtp.office365.com:587
smtp.office365.com:25
smtp.office365.com:483
[redacted]-com.mail.protection.outlook.com:25

Using 587 and 25, I get:
There was an error sending mail from '[redacted]@[redacted]' to '[redacted]@[redacted]': unable to establish SMTP connection to smtp.office365.com port 25

Using 483, I get:
The new value for smtpserver is invalid: Cannot connect to smtp.office365.com using port 483.

Using the direct-send SMTP server, I get:
There was an error sending mail from '[redacted]@[redacted]' to '[redacted]@[redacted]': unable to establish SMTP connection to [redacted]-com.mail.protection.outlook.com port 25

********** smtp_ssl **********

on
off

Using 'on', I get the error messages shown above.
Using 'off', I get:
There was an error sending mail from '[redacted]@[redacted]' to '[redacted]@[redacted]': failed AUTH: Command unknown: 'AUTH'

The mail_delivery_method drop-down does *not* have an SMTP-TLS option; it has Sendmail, SMTP, Test, None.

********** checksetup.pl **********

checksetup.pl indicates that almost everything is ok/found with the exception of:
DBD-SQLite
DBD-Oracle
DBD-Pg
PatchReader
Email-Reply
Apache-SizeLimit
Cache-Memcached
File-Copy-Recursive
File-Which
mod_rewrite

In general, the output from checksetup.pl looks fine, I don't see any glaring error messages or warnings.

********** access.log **********

Shows a normal GET request for /bugzilla/createaccount

********** error.log **********

Shows nothing.





Thorsten Schöning

unread,
May 25, 2018, 3:16:30 AM5/25/18
to support-...@lists.mozilla.org
Guten Tag Alexander Farley,
am Freitag, 25. Mai 2018 um 01:57 schrieben Sie:

> SMTP email from Bugzilla is working using Gmail;

What's the exact settings you were using?

> smtp.office365.com:587

From my understanding, this with smt_ssl on should be the way to go.
Enable smtp_debug as well and look at the web server error log. If you
have some kind of firewall filtering between you and MS, check that as
well, maybe using Wireshark.

Additionally have a look at OpenSSL-packages, checksetup.pl doesn't
know all 3rd dependencies need by some library. In the past
openssl-dev or such was missing for some users.

Mit freundlichen Grüßen,

Thorsten Schöning

--
Thorsten Schöning E-Mail: Thorsten....@AM-SoFT.de
AM-SoFT IT-Systeme http://www.AM-SoFT.de/

Telefon...........05151- 9468- 55
Fax...............05151- 9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow

Alexander Farley

unread,
May 25, 2018, 1:24:46 PM5/25/18
to
The working settings for Gmail were:
smtp.gmail.com:483
smtp_ssl:on

And of course I had Gmail credentials instead of my Office365/Outlook credentials.

I have a few more observations:

1) I'm able to send SMTP email manually using smtp.gmail.com:587 using the following command:
openssl s_client -CApath /etc/ssl/certs -starttls smtp -crlf -quiet -connect smtp.gmail.com:587

2) The above command fails if you leave out -CApath /etc/ssl/certs

3) Bugzilla indicates "unable to establish SMTP connection to smtp.gmail.com port 587".

So, I think this confirms:
-this is not a blocked-port issue; SMTP email has been successfully sent from my server using both port 483 and 587.
-the issue is probably not at the network/firewall level if the openssl command works
-the issue is probably not a missing openssl dependency, because the commmand-link SMTP transfer works

Another strange thing: even with smtp_debug enabled, and Bugzilla indicating "unable to establish SMTP connection to smtp.gmail.com port 587", I don't see anything showing up in error.log.



Alexander Farley

unread,
May 25, 2018, 4:59:03 PM5/25/18
to
I have just tried sending email with the command-line tool ssmtp on my Bugzilla server and I'm able to successfully send email using Office365 (587) this way. I think this shows that it's almost certainly not an upstream issue; this must be related to the mechanism that Bugzilla uses to transmit SMTP email.

Alexander Farley

unread,
May 25, 2018, 6:37:12 PM5/25/18
to
I was able to get this working by reading this discussion:
https://bugzilla.mozilla.org/show_bug.cgi?id=1182445

I ended up using Email::Sender::Transport::SMTPS as specified by Frédéric Buclin. I had to read the docs for Email::Sender::Transport::SMTPS to know how to format the parameters.

This seems to be specific to Office365 since it requires actual TLS; using Gmail, you can get away with regular SSL.

Anyway, thanks for the feedback.

Dimitar Paskov

unread,
Feb 5, 2019, 8:37:14 AM2/5/19
to
The simplest workaround without installing any additional fixes or modules is to just manually edit the params.json and set "smtp_ssl" : "starttls". Note however that changing the email settings in Bugzilla will overwrite your value so if you want a permanent solution you should edit Mailer.pm and in the if($method eq "SMTP") you should replace:

ssl => Bugzilla->params->{'smtp_ssl'},

with

$port eq "587" ? (ssl => "starttls") : (ssl => Bugzilla->params->{'smtp_ssl'}),

aravinds...@gmail.com

unread,
Jun 21, 2019, 1:54:01 AM6/21/19
to
This works perfectly

Thorsten Schöning

unread,
Jun 21, 2019, 3:07:18 AM6/21/19
to support-...@lists.mozilla.org
Guten Tag aravinds...@gmail.com,
am Freitag, 21. Juni 2019 um 07:54 schrieben Sie:

> This works perfectly

Your message would be more helpful for all users and their different
clients with actually quoting what "this" is. :-) Remember that not
all users have thread view of mails, don't even receive all mails at
all etc.

zawaw...@gmail.com

unread,
Jun 22, 2020, 1:25:35 AM6/22/20
to
On Friday, 21 June 2019 13:54:01 UTC+8, aravinds...@gmail.com wrote:
> This works perfectly

So what works perfectly? Please explain more.

Thorsten Schöning

unread,
Jun 22, 2020, 2:50:23 AM6/22/20
to support-...@lists.mozilla.org
Guten Tag zawaw...@gmail.com,
am Montag, 22. Juni 2020 um 07:25 schrieben Sie:

> So what works perfectly? Please explain more.

The referenced answer was the following:

http://mozilla.6506.n7.nabble.com/Office365-SMTP-unable-to-establish-SMTP-connection-tp375251p379182.html

Bit you should really read the whole thread and I don't recommend
changing Bugzilla core code. TLS seems to simply not be supported
currently:

https://bugzilla.mozilla.org/show_bug.cgi?id=1182445

You might prefer a different solution like a local sendmail to forward
your mails with TLS-support.
Reply all
Reply to author
Forward
0 new messages