問題描述:
公司郵箱發送到内部郵箱沒問題,在Foxmail上發送到外部郵箱如136,qq也沒問題。但是使用java代碼發送到外部郵箱有問題,網上找了很多都是些沒用的,後來和一個同僚一起研究找到了解決辦法。在這裡感謝他
異常資訊:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
解決方法:
commons-email改為高版本
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.2.2</version>
</dependency>
改為
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.4</version>
</dependency>