Spring Mail を使用して、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
test.email.username=demo@mydomain.net
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 <demo@mydomain.net>... Relaying denied