구글 어플 리케이션 엔진을 사용하여이 코드로 이메일을 보내기 만하면됩니다. 하지만 아무 일도 일어나지 않습니다. 메일 API를 사용하기 위해 구성해야하는 항목이 있습니까? 이것은 localhost에서 실행됩니다. Gmail을 메일 호스트로 사용하고 있습니다.구글 앱 엔진으로 이메일 보내기
String host = "smtp.google.com";
String to = "[email protected]";
String from = "[email protected]";
String subject = "this is a test";
String messageText = "test";
boolean sessionDebug = false;
// Create some properties and get the default Session.
Properties props = System.getProperties();
props.put("mail.host", host);
props.put("mail.transport.protocol", "smtp");
Session mailSession = Session.getDefaultInstance(props, null);
// Set debug on the Session
// Passing false will not echo debug info, and passing True will.
mailSession.setDebug(sessionDebug);
// Instantiate a new MimeMessage and fill it with the
// required information.
Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = { new InternetAddress(to) };
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(messageText);
// Hand the message to the default transport service
// for delivery.
Transport.send(msg);
그럼 GAE 프로젝트에서 이메일을 보낼 방법이 없습니까? 아니면 그냥이 방법을 사용하지 않습니까? – Nick
특정 주소에서만 가능하며 로컬 개발 서버는 전자 메일을 콘솔에 기록합니다 – jimr