<分区>
因此,我们的 GAE 应用程序中有一个非常好的、有效的电子邮件解决方案。我们可以根据需要从 noreply@company.com 发送电子邮件。 noreply@company.com 是一个 GAE 帐户,在我们的应用程序中具有开发访问权限。
接下来,我们要使用与此帐户关联的 SMTP 服务器。为此,我们需要升级帐户以使用 gmail。在我们进行此操作时,Google 通知我们需要将一个 gmail 地址与该帐户相关联 - 我们选择了 company.noreply@gmail.com。 noreply@company.com 将成为备用地址。然后我们将 noreply@company.com 设为默认地址。现在我们可以远程使用 smtp 服务器,从 noreply@company.com 发送电子邮件。太好了。
第二天,我们发现这破坏了我们 GAE 应用程序上的邮件程序。在权限中,该帐户已从 noreply@company.com 更改为 company.noreply@gmail.com。重新邀请 noreply@company.com 成功,但最终账号还是 company.noreply@gmail.com。 noreply@company.com 现在无权发送邮件,或者换句话说,我们无法将 noreply@company.com 设置为发件人地址,即使这是一个授权帐户。
有什么方法可以恢复通过 GAE 从 no reply@company.com 发送电子邮件的能力吗?
--
当前代码:
final Properties props = new Properties();
final Session session = Session.getDefaultInstance(props, null);
try {
final Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("noreply@company.com"));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
msg.setSubject(subject);
msg.setContent(content, contentType);
Transport.send(msg);
} catch (final MessagingException ex) {
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
}
我们已经邀请 noreply@company.com 成为管理员,它已被成功接受,并列在 GAE 权限中,尽管在备用地址下。
这是 GAE 在尝试使用该批准的帐户发送电子邮件时给出的错误:
Internal Server Error (500) - The server encountered an unexpected condition which prevented it from fulfilling the request
at org.restlet.resource.ServerResource.doHandle(ServerResource.java:517)
at org.restlet.resource.ServerResource.post(ServerResource.java:1216)
...
Caused by: java.lang.IllegalArgumentException: Unauthorized Sender: Unauthorized sender
at com.google.appengine.api.mail.MailServiceImpl.doSend(MailServiceImpl.java:109)
at com.google.appengine.api.mail.MailServiceImpl.send(MailServiceImpl.java:34)
at com.glasseystrategy.jstratpad.util.MailUtils.sendEmailReport(MailUtils.java:400)
...