現在SpringBootを使用し、メール送信機能を作成しています。
http://ksby.hatenablog.com/entry/2015/04/22/022930#MAIL001MailBuilder.java
を参考に作成しているのですが、MailConnectExceptionが発生しうまくいかず、
調べているのですが原因が良く分かりません。
どなたか分かる方がいらっしゃいましたら、ご教示いただければと思います。
よろしくお願い致します。
■例外メッセージ
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.mail.MailSendException: Mail server connection failed; nested exception is com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1;
nested exception is:
java.net.SocketException: Network is unreachable: connect. Failed messages: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1;
nested exception is:
java.net.SocketException: Network is unreachable: connect; message exceptions (1) are:
Failed message 1: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1;
nested exception is:
java.net.SocketException: Network is unreachable: connect] with root cause
現在のソースおよび設定状況は以下のとおりです。
■smtpサーバ
・smtp4devを使用。
・DomainName:localhost
・port :25
・ListenInterface:127.0.0.1
■application.properties
spring.mail.host= localhost spring.mail.port= 25
■pom.xml
xml
1 <!-- Spring boot Mail --> 2 <dependency> 3 <groupId>org.springframework.boot</groupId> 4 <artifactId>spring-boot-starter-mail</artifactId> 5 </dependency>
■メール送信クラス
java
1 /** メール送信サービス */ 2 @Autowired 3 MailSender mailSender; 4 private void sendMail(ModalSaveForm form){ 5 6 SimpleMailMessage msg = new SimpleMailMessage(); 7 8 msg.setFrom("test@test.com"); 9 msg.setTo("test@test.com"); 10 msg.setSubject("テストメール");//タイトルの設定 11 msg.setText("Spring Boot より本文送信"); //本文の設定 12 13 mailSender.send(msg); 14 }

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/20 02:54
2016/10/20 03:17