Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Office 365 #497

Closed
rhodrykorb opened this issue Jun 23, 2014 · 15 comments

Comments

Projects
None yet
6 participants
@rhodrykorb
Copy link

commented Jun 23, 2014

A client is now using Office 365 (Exchange Online) for their corporate email system.

This SwiftMailer code seems to work for other SMTP servers, but not Office365:
Smtp::newInstance('smtp.office365.com', 587, 'tls')->setUsername('username@mydomain.com')->setPassword('Password1');

The error being outputted is:
Connection could not be established with host smtp.office365.com [An attempt was made to access a socket in a way forbidden by its access permissions. #10013]

@xdecock

This comment has been minimized.

Copy link
Member

commented Jun 23, 2014

wow, never seen this error, are you running windows?

Can you triple check your firewall settings?

On Mon, Jun 23, 2014 at 10:36 AM, Rhodry Korb notifications@github.com
wrote:

A client is now using Office 365 (Exchange Online) for their corporate
email system.

This SwiftMailer code seems to work for other SMTP servers, but not
Office365:
Smtp::newInstance('smtp.office365.com', 587, 'tls')->setUsername('
username@mydomain.com')->setPassword('Password1');

The error being outputted is:
Connection could not be established with host smtp.office365.com [An
attempt was made to access a socket in a way forbidden by its access
permissions. #10013]


Reply to this email directly or view it on GitHub
#497.

Xavier De Cock
GPG Fingerprint: 93CA EE3F 9F57 5BE1 AE4A 794D 3C74 CA9E E7A5 0C1B
GPG Id: 0xE7A50C1B

@rhodrykorb

This comment has been minimized.

Copy link
Author

commented Jun 23, 2014

@xdecock Yup - was a firewall (and AV) issue! It's just odd how it worked for other providers and just not O365.

Now I am getting:
Failed to authenticate on SMTP server with username "username@mydomain.com" using 1 possible authenticators

Which is looking like it is perhaps more a O365 issue.

@aniruddhaad

This comment has been minimized.

Copy link

commented Feb 9, 2015

Here is another observation with swiftmailer 5.3.1.
For me it worked on windows 7 with XAMPP.
Its NOT working on production CENT OS 5.1 (PHP version 5.4.37)

Continuously getting error -
Connection could not be established with host smtp.office365.com [Network is unreachable #101]

A little variation in ->setAuthMode() to NTLM, LOGIN, XOAUTH2, CRAM-MD5...
got one of following (with Swift_Plugins_Loggers_EchoLogger)-

  1. Connection could not be established with host smtp.office365.com [Connection timed out #110]
    &
  2. Connection could not be established with host smtp.office365.com [Connection timed out #101]

Even opened port 587 from firewall & encryption to "tls" but no luck.

@aniruddhaad

This comment has been minimized.

Copy link

commented Feb 9, 2015

Another test with smtp.office365.com Port 25, encryption tls, setAuthMode('LOGIN') works on production.

@poul-kg

This comment has been minimized.

Copy link

commented May 10, 2016

@rhodrykorb Have you found any solution? I have exactly the same issue.

@aniruddhaad

This comment has been minimized.

Copy link

commented May 10, 2016

Following thing works :)

->setHost("smtp.office365.com")
->setSourceIp('x.x.x.x') //replace x with your ip address
->setLocalDomain('example.com')
->setPort(25)
->setEncryption('tls')
->setAuthMode('LOGIN');

So port 25 with tls (I thought if tls then port must be 587 earlier but it works with 25 port with tls)
Hope it helps ;)

@cordoval

This comment has been minimized.

Copy link
Contributor

commented Jan 9, 2017

you forgot the username and password lines i assume

@aniruddhaad

This comment has been minimized.

Copy link

commented Jan 9, 2017

I didn't wrote... As its standard function call with single value as parameter I.e. Username & password

@aniruddhaad

This comment has been minimized.

Copy link

commented Jan 9, 2017

Well... So far office 365 worked OK but few months back we have switch to mandril as we were constantly getting host not found (php_getaddreas not able to.... Bla bla)...
Mandril or send grid works like charm.. No waiting for establishing connection like office 365...

@cordoval

This comment has been minimized.

Copy link
Contributor

commented Jan 9, 2017

that is if no hippa requirement is in place. However office 365 is good option for hippa apps. Could this problem you speak of be worked around somehow? any suggestions for those staying with office 365?

@aniruddhaad

This comment has been minimized.

Copy link

commented Jan 9, 2017

Well after using office 365 for couple of years... It did not worked smoothly, rather had to tweak code few times to get it working again... So its not good option to go with office 365 at least for sending email from php swift mailer. Though It works great with email client like outlook etc.

Work around could be grab it of smtp.office365.com but the iPhone keeps changing... So using it will brake the code.

@aniruddhaad

This comment has been minimized.

Copy link

commented Jan 9, 2017

Pardon... Auto complete by phone
#grab ip address of smtp.office365.com but the ip keeps changing... So using it will brake the code.

@cordoval

This comment has been minimized.

Copy link
Contributor

commented Jan 9, 2017

works like a charm thanks! 👍

@cordoval

This comment has been minimized.

Copy link
Contributor

commented Jan 9, 2017

this issue can be closed i think

@fabpot fabpot closed this Jan 9, 2017

@cordoval

This comment has been minimized.

Copy link
Contributor

commented Jul 21, 2017

For those still with it, port is not 25, it is MAILER_PORT=587

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.