How to send an email using MS exchange server

前端 未结 8 2332
一整个雨季
一整个雨季 2020-12-13 16:58

I am trying to sent an email using my company\'s mail server. But I am getting the following exception

Caused by: com.sun.mail.smtp.SMTPSendFailedException:          


        
相关标签:
8条回答
  • 2020-12-13 17:35

    Simple Java Mail worked for me. The only thing you have to check is for correct hostname, username, port and password TransportStrategy.SMTP_TLS:

    new Mailer(host, port, username, password, TransportStrategy.SMTP_TLS).sendMail(email);
    
    0 讨论(0)
  • 2020-12-13 17:39

    The 5.7.1 is probably caused by exchange and not your code. You may just need to enable relaying on the server. Either for anonymous users or from a certain IP address. I'm not an expert on Exchange but I have got this working before. Here is the last solution I tested that works:

    If a 5.7.1 error is encountered when trying to send an email via SMTP on an exchange server when the user has been authenticated..

    For ref the issue you just had was caused by a setting on the Exchange 2007 server – this would not normally be a problem on 2003 server

    Fixed by doing below...

    You can set this authentication setting via the GUI

    • In Server configuration / Hub Transport / Default <ServerName>
    • Right click, properties, Permission Groups
    • Check "Anonymous users" and then click OK

    Obviously anon users is not too secure but you could see if this solves the problem.

    0 讨论(0)
提交回复
热议问题