我正在分享一个链接,您可以通过该链接在 GAE 中配置电子邮件服务。
https://developers.google.com/appengine/docs/java/mail/usingjavamail
您需要在构建路径中配置 javax.mail jar 来配置它。
并确保您使用您的管理员电子邮件发送电子邮件,您正在使用这些电子邮件部署您的应用程序。这只会在服务器上部署一次。
发送电子邮件的代码
import java.io.UnsupportedEncodingException;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class SendMail {
public void sendMail(String sendEmailFrom,String sendMailTo,String recipientName,String messageSubject,String messageText){
Properties prop = new Properties();
Session session = Session.getDefaultInstance(prop,null);
try{
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(sendEmailFrom));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(sendMailTo, "Mr./Ms. "+recipientName));
msg.setSubject(messageSubject);
msg.setText(messageText);
Transport.send(msg);
System.out.println("Successfull Delivery.");
} catch (AddressException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}