我們正在使用Spring郵件發送從java應用程序的電子郵件 org.springframework.mail.javamail.JavaMailSenderImpl例外:被拒絕的傳遞
春天電子郵件配置是
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl" autowire-candidate="default">
<property name="host" value="${test.email.host}" />
<property name="port" value="${test.email.port}" />
<property name="username" value="${test.email.username}" />
<property name="password" value="${test.email.password}" />
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
</props>
</property>
</bean>
的Java代碼快照
@Autowired(required = true)
@Qualifier("errorMessageMailSender")
JavaMailSenderImpl mailSender;
..............
..............
try {
MimeMessage mailMessage = buildEmailMimeMessage(properties,mimeMultipart);
logger.info(String.format("Built MimeMessage object is <%s>",mailMessage));
if (mailMessage != null) {
mailSender.send(mailMessage);
logger.info("Mail sent Successfully");
}else{
logger.info("Mail send failed as Mail message object construction failed.");
}
result=true;
} catch (Exception e) {
logger.error("An exception occurred while sending mail :: " + e.getMessage());
}
屬性文件
test.email.host=mail.mydomain.net
test.email.port=2525
[email protected]
test.email.password=mypassword
但我們例外下面,並沒有被髮送的電子郵件
An exception occurred while sending mail :: Failed messages: javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 <[email protected]>... Relaying denied
檢查http://www.gammadyne.com/relaying_denied.htm,谷歌的第一個結果 –
這是一個SMTP問題,而不是Java問題... – fge
如果我保持我的用戶名和密碼屬性爲空白,將smtp auth屬性設置爲true,會導致這個問題? –