我在我的 应用程序中使用Google App Engine的MailService功能。它在一个应用程序中正常工作,没有任何问题 但是相同的代码在另一个应用程序中不起作用。我无法将 列出。请帮忙。以下是我使用 发送邮件的一段代码。Google App Engine Java Mail的奇怪问题
public static void sendHTMLEmail(String from, String fromName, String
to, String toName, String subject, String body) {
_logger.info("entering ...");
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
_logger.info("got mail session ...");
String htmlBody = body;
try {
Message msg = new MimeMessage(session);
_logger.info("created mimemessage ...");
msg.setFrom(new InternetAddress(from,
fromName));
_logger.info("from is set ...");
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(
to, toName));
_logger.info("recipient is set ...");
msg.setSubject(subject);
_logger.info("subject is set ...");
Multipart mp = new MimeMultipart();
MimeBodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(htmlBody, "text/html");
mp.addBodyPart(htmlPart);
_logger.info("body part added ...");
msg.setContent(mp);
_logger.info("content is set ...");
Transport.send(msg);
_logger.info("email sent successfully.");
} catch (AddressException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
System.err.println(e.getMessage());
}
}
当我看到日志(服务器管理控制台),它打印 声明“的内容设置...”后面还有什么在 日志。邮件不发送。有时我在 上面的语句被打印(并且不发送邮件)后出现以下错误。
com.google.appengine.repackaged.com.google.common.base.internal.Finalizer getInheritableThreadLocalsField:无法访问 Thread.inheritableThreadLocals。参考终结器线程将 继承线程本地值。
但邮件配额使用量不断增加。
请记住,这在一个应用程序中正常工作,但不能在其他应用程序中正常工作。我是 ,在这两个应用程序中使用同一组电子邮件地址(对于from和 )。
我真的很坚持这一点。感谢任何帮助。
谢谢。 Velu