无法在Google App Engine上发送电子邮件

陈冠希:

我尝试使用Javamail发送电子邮件。但是,我收到以下消息:

javax.mail.SendFailedException: Send failure (javax.mail.MessagingException: Illegal Arguments (java.lang.IllegalArgumentException: Bad Request: ))

我试图从管理员帐户(用于上传应用程序)以及我登录到该应用程序的用户帐户发送电子邮件。(来自UserService - getCurrentUser().getEmail())都失败了。

我想知道是否需要设置任何特殊设置?

    Properties props = new Properties();
    Session session = Session.getDefaultInstance(props, null);    
    Message msg = new MimeMessage(session);
    UserService userService = UserServiceFactory.getUserService();
    String email = userService.getCurrentUser().getEmail();
    //Or
    //String email = "[email protected]";
    msg.setFrom(new InternetAddress(email));
    msg.addRecipient(Message.RecipientType.TO,
                     new InternetAddress("[email protected]"));
    msg.setSubject("Test Email");
    msg.setText("Nobody");
    Transport.send(msg);
视力:

真的很奇怪。我只写了以下示例:

UserService userService = UserServiceFactory.getUserService();
String thisURL = request.getRequestURI();
if (request.getUserPrincipal() != null) {
    response.getWriter().println("<p>Hello, " +
                                request.getUserPrincipal().getName() +
                                "!  You can <a href=\"" +
                                userService.createLogoutURL(thisURL) +
                                "\">sign out</a>.</p>");
    Properties props = new Properties();
    Session mailSession = Session.getDefaultInstance(props, null);    
    Message msg = new MimeMessage(mailSession);
    String email = userService.getCurrentUser().getEmail();
    //Or
    //String email = "[email protected]";
    msg.setFrom(new InternetAddress(email));
    msg.addRecipient(Message.RecipientType.TO,
                     new InternetAddress("[email protected]"));
    msg.setSubject("Test Email");
    msg.setText("Nobody");
    Transport.send(msg);
    response.getWriter().println("<p>Sent email!</p>");
} else {
    response.getWriter().println("<p>Please <a href=\"" +
                                userService.createLoginURL(thisURL) +
                                "\">sign in</a>.</p>");
}

没有例外,我确实收到了电子邮件。您确定实际应用中没有更多操作吗?

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用Google App Engine发送电子邮件

无法从nodemailer发送电子邮件

无法在Heroku上使用Gmail发送电子邮件

无法通过烧瓶邮件发送电子邮件

保存Google App Maker发送的电子邮件地址

如何在Google App脚本中向多个收件人发送电子邮件

Nodemailor无法在跨域上发送电子邮件

Mail Gun电子邮件无法在Google App Engine上的烧瓶中运行

如何使用HTML发送Google App脚本电子邮件

从Google App脚本发送电子邮件时出错

Google App脚本无法通过触发器发送自动电子邮件

google App脚本:如何在发送电子邮件中设置条件规则?

无法在Ruby上发送电子邮件

plesk面板上的Smtp:无法发送电子邮件

无法从PHP发送电子邮件

有没有一种方法可以更改Google App Engine Mail发送的电子邮件中的地址/电子邮件ID

Gitlab无法发送电子邮件

Poco无法发送电子邮件

使用别名电子邮件地址从Google App Engine发送邮件

发送电子邮件烧瓶Google App引擎-无效的发件人格式

为什么我不能在Google App Engine上发送电子邮件?

来自Google App Engine的电子邮件未到达

Django无法发送电子邮件

在Google App Engine(Java)中发送带有嵌入式图像的电子邮件

如何通过Google App Engine使用JavaMail发送电子邮件

通过Gmail API Google App Engine发送电子邮件

在 Google App Engine 上收不到电子邮件

我想通过 Javascript/Google App Script 中的 API 响应向用户发送电子邮件?

Google App Script 如何在发送自动电子邮件时添加特定的抄送电子邮件