javamail api를 통해 smtp 서버를 사용하여 이메일을 보내려고했습니다. 내가 인증을 사용하지 않도록 노력했다smtp server-javamail을 사용하여 메일을 보낼 수 없습니다.
private Session getSession() {
Authenticator authenticator = new Authenticator();
Properties properties = System.getProperties();
properties.setProperty("mail.smtp.submitter", authenticator.getPasswordAuthentication().getUserName());
properties.setProperty("mail.smtp.auth", "false");
properties.setProperty("mail.smtp.starttls.enable", "false");
properties.setProperty("mail.smtp.host", "smtp.hostname.com");
properties.setProperty("mail.smtp.port", "587");
properties.setProperty("mail.smtp.ssl.trust", "smtp.hostname.com");
properties.setProperty("java.net.preferIPv4Stack" , "true");
return Session.getInstance(properties, authenticator);
}
private class Authenticator extends javax.mail.Authenticator {
private PasswordAuthentication authentication;
public Authenticator() {
String username = "username";
String password = "password";
authentication = new PasswordAuthentication(username, password);
}
protected PasswordAuthentication getPasswordAuthentication() {
return authentication;
}
}
일부 게시물에 의해 제안도에 대한 해상도에 넣어 :
여기javax.mail.MessagingException: Could not connect to SMTP host: smtp.host.com, port: 587;
nested exception is:java.net.SocketException: Permission denied: connect
내가 메일에 대한 Properties
및 Session
개체를 만드는 방법은 다음과 같습니다 나는 다음과 같은 오류가 발생합니다 이 게시물에 따른 IPv4 환경 설정 : JavaMail API to iMail -- java.net.SocketException: Permission denied: connect
하지만 여전히 동일한 오류가 발생합니다. 이 문제가 해결 될 수있는 다른 방법이 있습니까?
감사합니다.
예를 들어 Thunderbird와 같은 일반 메일 클라이언트에서 동일한 구성 값을 사용하여 유효한지 확인 했습니까? – mjn
[JavaMail API에서 iMail 로의 가능한 복제 - java.net.SocketException : 권한이 거부되었습니다 : 연결] (http://stackoverflow.com/questions/12901475/javamail-api-to-imail-java-net-socketexception-permission -denied-connect) – mjn