녕하세요
자바 공부중인 대학생입니다
자바메일을 통해서 저의 대학교 웹메일 SMTP를 통해서 메일을 보내는 소스를 실습중인데
저의 학교웹메일 SMTP를 통해서 제 학교웹메일 즉 자신에게 보내기는 무리없이 됩니다
하지만 네이버, 다음으로 보내지지 않습니다. 이클립스에서 메세지를 보냈다는 문구가 뜨지만
네이버나 다음 메일을 열어보면 메일이 도착하지 않습니다
제 안드로이드폰에서 학교웹메일 계정을 설정하여 보내면 잘 보내지지만
이클립스에서 자바메일을 이용해 보내면 도착하지 않습니다
무엇이 문제일까요
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class mailtest {
public static void main(String args[]) throws MessagingException{
// 메일 관련 정보
String host = "학교웹메일서버";
final String username = "로그인아이디";
final String password = "로그인비밀번호";
String port="포트번호";
// 메일 내용
String recipient ="받는주소";
String subject = "왜 안되냐!!!";
String body = "내용 무";
Properties props = System.getProperties();
props.put("mail.transport.pro*tocol","smtp");
props.put("mail.store.pro*tocol", "smtp");
props.put("mail.smtp.host", host);
props.put("mail.smtp.port", port);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.ssl.enable", "true");
// props.put("mail.smtp.ssl.trust", host);
Session sessi new javax.mail.Authenticator() {
String un=username;
String pw=password;
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(un, pw);
}
});
session.setDebug(true); //for debug
Message mimeMessage = new MimeMessage(session);
mimeMessage.setFrom(new InternetAddress("보내는사람주소"));
mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(recipient));
mimeMessage.setSubject(subject);
mimeMessage.setText(body);
Transport.send(mimeMessage);
}
}
댓글 0