4,563,804 th visitor since 2017.2.1 ( Today : 181 )
Programming
No. 374
Name. swindler
Subject. javax.mail 인증통해서 메일 발송시
Main Cate. Java
Sub Cate.
Date. 2007-06-21 10:44
Hit. 6970 (211.181.247.3)
File.
인증없이 Session 을 만들때는 아래와 같고
Session session=Session.getDefaultInstance(properties, null);

인증필요시는 아래처럼 생성한다.
Authenticator auth = new SMTPAuthenticator(smtpId, smtpPwd);
Session session=Session.getInstance(properties, auth);


public final class SMTPAuthenticator extends javax.mail.Authenticator {

private String id;
private String pw;

public SMTPAuthenticator(String id, String pw) {
this.id = id;
this.pw = pw;
}

protected javax.mail.PasswordAuthentication getPasswordAuthentication() {
return new javax.mail.PasswordAuthentication(id, pw);
}

}


이렇게 했으나 실제 sendmail 로그를 찾아보니 인증을 하지 않는다.
그건

properties.put("mail.smtp.auth", "true");

를 추가해서 인증하라고 설정을 해야 된다.

[바로가기 링크] : http://coolx.net/cboard/develop/374



swindler transport.connect 할때도 id, password 를 인자로 넣어줘야 됨 2011-12-28
swindler javamail 패키지가 구버전인 경우 false를 줘도 인증을 시도하는 경우가 있다. 2014-01-20
Name
Password
Comment
Copyright © 1999-2017, swindler. All rights reserved. 367,611 visitor ( 1999.1.8-2004.5.26 ), 2,405,771 ( -2017.01.31)

  2HLAB   2HLAB_Blog   RedToolBox   Omil   Omil_Blog