1

我以 github 项目 jappstart https://github.com/taylorleese/google-app-engine-jappstart 为例,但是在 prod 中将应用程序部署到 app-engine 后,无法使应用程序发送授权电子邮件。

应用引擎日志中也没有生成未经授权的发件人错误,所以看起来我使用的是正确的发件人电子邮件。我意识到在任务队列中生成了邮件队列,但按下立即运行按钮没有帮助:/有什么想法吗?

产品属性文件

google.app.id= -Application Identifier-
google.app.version=1

google.jsapi.http.key=enterKey
google.jsapi.https.key=enterKey

application.secureChannel=https
application.hostname= -Application Identifier Alias-

jquery.ver=1.7.1

mail.fromAddress= -owner/admin email-

激活电子邮件方法

public final void sendActivationEmail(final UserAccount user,
    final String locale)
    throws MessagingException {
    final Properties props = new Properties();
    final Session session = Session.getDefaultInstance(props, null);
    final Message message = new MimeMessage(session);
    final Multipart multipart = new MimeMultipart();
    final MimeBodyPart htmlPart = new MimeBodyPart();
    final MimeBodyPart textPart = new MimeBodyPart();

    message.setFrom(new InternetAddress(getFromAddress()));
    message.addRecipient(Message.RecipientType.TO,
        new InternetAddress(user.getEmail()));

    message.setSubject(messageSource.getMessage("mail.subject", null,
        new Locale(locale)));

    textPart.setContent(messageSource.getMessage("mail.body.txt",
        new Object[] {getHostname(), user.getActivationKey()},
        new Locale(locale)), "text/plain");

    htmlPart.setContent(messageSource.getMessage("mail.body.html",
        new Object[] {getHostname(), user.getActivationKey()},
        new Locale(locale)), "text/html");

    multipart.addBodyPart(textPart);
    multipart.addBodyPart(htmlPart);
    message.setContent(multipart);

    Transport.send(message);
}
4

0 回答 0