Office365 SMTP: "unable to establish SMTP connection"

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Office365 SMTP: "unable to establish SMTP connection"

Alexander Farley
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.





_______________________________________________
support-bugzilla mailing list
[hidden email]
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put [hidden email] in the To: field when you reply.
Reply | Threaded
Open this post in threaded view
|

Re: Office365 SMTP: "unable to establish SMTP connection"

Alexander Farley
On Friday, May 25, 2018 at 1:16:30 AM UTC-6, Thorsten Schöning wrote:

> 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: [hidden email]
> 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

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.



_______________________________________________
support-bugzilla mailing list
[hidden email]
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put [hidden email] in the To: field when you reply.
Reply | Threaded
Open this post in threaded view
|

Re: Office365 SMTP: "unable to establish SMTP connection"

Alexander Farley
On Friday, May 25, 2018 at 11:24:46 AM UTC-6, Alexander Farley wrote:

> On Friday, May 25, 2018 at 1:16:30 AM UTC-6, Thorsten Schöning wrote:
> > 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: [hidden email]
> > 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
>
> 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.

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.

_______________________________________________
support-bugzilla mailing list
[hidden email]
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put [hidden email] in the To: field when you reply.
Reply | Threaded
Open this post in threaded view
|

Re: Office365 SMTP: "unable to establish SMTP connection"

Alexander Farley
On Friday, May 25, 2018 at 2:59:03 PM UTC-6, Alexander Farley wrote:

> On Friday, May 25, 2018 at 11:24:46 AM UTC-6, Alexander Farley wrote:
> > On Friday, May 25, 2018 at 1:16:30 AM UTC-6, Thorsten Schöning wrote:
> > > 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: [hidden email]
> > > 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
> >
> > 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.
>
> 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.

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.
_______________________________________________
support-bugzilla mailing list
[hidden email]
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put [hidden email] in the To: field when you reply.