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:
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);
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
Obviously anon users is not too secure but you could see if this solves the problem.