klmat's avatar
Level 1

Failed sending email when using microsoft exchange email account

I'm trying to add an exchange email account in my laravel application so that my emails will be sent from it.

I've tried mailtrap and it works fine as expected.

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=null

When I change these credentials to the actual email provided from my client, the emails are not sent.

My client has his own intranet with internal Microsoft exchange server.

I returned to laravel log file to find the following error:

local.INFO: Swift_TransportException: Failed to authenticate on SMTP server with username "[email protected]" using 1 possible authenticators. Authenticator NTLM returned Swift_TransportException: Expected response code 235 but got code "535", with message "535 5.7.3 Authentication unsuccessful

Note that the credentials are correct, and I tried to change the given email account with another one and got the same result.

Any suggestion?

0 likes
2 replies
MikeMacDowell's avatar

@klmat what Port and Encryption are you using?

And do you have a domain prefix requirement for the username on the exchange server?

We have this working internally with no issues, so it does work.

Who are you trying to send the email as? The account you're using to authenticate must have permission to send as the 'from' address in mail.php or whatever from address you're setting when you send the email.

1 like
klmat's avatar
Level 1

@MikeMacDowell Thank you for your help. The issue is fixed with strange unexpected solution! , I had to make the username, password and encryption to be null in config/mail.php because the exchange server admin created the account as doesn't require autheintication!

Thank you for your help.

Please or to participate in this conversation.