[SMTP] Lý do phát sinh exception khi gửi mail (SMTPSendFailedException / javax.mail.MessagingExcept)
Mình làm gửi email cho user bằng email của công ty thì hầu hết email vẫn gửi được bình thường, nhưng thi thoảng lại bị phát sinh exception. Mình cũng xử lý bằng cách gửi lại email được rồi, nhưng mình muốn tìm xem căn bản vấn đề phát sinh do đâu để giải quyết triệt để luôn.
Ai biết gợi ý giúp mình với. Cảm ơn mọi người.
Exception log 1)
com.sun.mail.smtp.SMTPSendFailedException: [EOF]
at com.sun.mail.smtp.SMTPTransport.issueSendCommand
at com.sun.mail.smtp.SMTPTansprot.finishData
at com.sun.mail.smtp.SMTPTransport.sendMessage
at javax.mail.TransPort.send0
at javax.mail.TransPort.send
Exception log 2)
javax.mail.MessagingException: Can’t send command to SMTP host
at com.sun.mail.smtp.SMTPTransport.sendCommand
at com.sun.mail.smtp.SMTPTransport.sendCommand
at com.sun.mail.smtp.SMTPTransport.close
at javax.mail.Transport.send0
at javax.mail.Transport.send
-----
Mình đang dùng SSL và ở đoạn triển khai bằng service thì giá trị được cài như dưới đây.
SMTP_PROT là SSL nên mình dùng 465.
props.put("mail.smtp.host", SMTP_HOST); // SMTP Host
props.put("mail.smtp.socketFactory.port", SMTP_PORT); // SSL Port
props.put("mail.debug", "debug");
props.put("mail.smtp.auth", "true"); // Enabling SMTP Authentication