2
Java 응용 프로그램을 통해 전자 메일을 보내려고합니다. 호스팅 서비스 제공 업체 (cyberhost.in)가 제공 한 전자 메일 계정에서 전자 메일을 보내려고합니다. 응용 프로그램을 실행할 때마다 SSL 예외가 발생합니다.전자 메일을 보낼 때 Ssl 예외가 발생합니다.
1) 코드
public class Email {
public static void main(String[] args) throws UnsupportedEncodingException {
Properties props = new Properties();
props.put("mail.smtp.host", "v1.cyberns.net");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("[email protected]",
"********");
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("[email protected]",
"heyywassup"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("[email protected]"));
message.setSubject("Testing Subject");
message.setText("Dear Mail Crawler,"
+ "\n\n No spam to my email, please!");
Transport.send(message);
System.out.println("Done");
} catch (MessagingException e) {
throw new RuntimeException(e);
}
}
}
2) 예외
>>>>>Sending data QUIT<<<<<<
Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: javax.net.ssl.SSLException: Connection has been shutdown: javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair
at com.bean.Email.main(Email.java:47)
Caused by: javax.mail.MessagingException: javax.net.ssl.SSLException: Connection has been shutdown: javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair
at org.apache.geronimo.javamail.transport.smtp.SMTPTransport.sendLine(SMTPTransport.java:1702)
at org.apache.geronimo.javamail.transport.smtp.SMTPTransport.sendQuit(SMTPTransport.java:1459)
at org.apache.geronimo.javamail.transport.smtp.SMTPTransport.close(SMTPTransport.java:732)
at javax.mail.Transport.send(Transport.java:144)
at javax.mail.Transport.send(Transport.java:48)
at com.bean.Email.main(Email.java:42)