简体   繁体   中英

Laravel - Sending Emails Through Exchange Server

For my Laravel 5.1 app, I have an on-premise Exchange server and user account that I want to sent emails through. Below are the values in my .env file:

MAIL_DRIVER=smtp
MAIL_HOST=[IP ADDRESS]
MAIL_PORT=587
MAIL_USERNAME=[USERNAME]
MAIL_PASSWORD=[PASSWORD]
MAIL_ENCRYPTION=null

I get an error when using tls as the encryption value and just for the sake of testing, I've been using null for now. But then I get the error of Failed to authenticate on SMTP server with username "*******" using 1 possible authenticators

I'm unsure of where I should start for troubleshooting. It seems that it's using NTLM Authentication for verifying the credentials. Should I check the Exchange server to see if it's set up for that? The credentials I used are correct. Or is there something wrong with my config?

Thanks in advance.

As you are using port 587 ( MSA ) you might wish to switch to port 465 ( smtps ) in your application to test that. Because MSA should accept email after authentication (eg after SMTP AUTH).

Addition check if you can send an email via plain telnet over port 25 (as explained here for example). If you require TLS then you can check that with OpenSSL as explained here for example if there is an selfsigned SSL certificate on the Exchange server which isn´t trusted in the application (eg Laravel).

Based on that troubleshooting above you might get a better error message which isn´t application based. This can then be used to do the troubleshooting on the MS Exchange server (if needed because of the reason that the telnet test on the server which host the Laravel app failed).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM