应用程序引擎邮件未发送 [英] app engine mail is not sending

查看:108
本文介绍了应用程序引擎邮件未发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有App引擎应用程序。



我有一个名为 push 的servlet。我部署了应用程序并调用了我的servlet GET方法。

在我的servlet中,我有两个方法:

1)首先是:(该方法不发送邮件,我不明白为什么?我没有错误)

  void sendMail ()抛出UnsupportedEncodingException {

属性props = new Properties();
Session session = Session.getDefaultInstance(props,null);
String msgBody =TEXT HERE;
尝试{
消息msg = new MimeMessage(session);
msg.setFrom(新InternetAddress(ownerMail,Example.com Admin));
msg.addRecipient(Message.RecipientType.TO,new InternetAddress(maria.chiamaia@gmail.com,Mr. User));
msg.setSubject(您的PDF有问题);
msg.setText(msgBody);
$ b $ catch(AddressException e){
log(error,e);
} catch(MessagingException e){
log(error,e);
}

}

我也调用另一种方法: (这是有效的!)

void snedTest(){

  String to =somebody; 
来自=ownerMail的字符串;
String host =localhost:8080;
属性properties = System.getProperties();
properties.setProperty(mail.smtp.host,host);
Session session = Session.getDefaultInstance(properties);

尝试{

MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
message.setSubject(This is the Line Line!);
message.setText(This is actual message);
Transport.send(message);
System.out.println(发送邮件成功....);
} catch(MessagingException mex){
mex.printStackTrace();
}

}

第一种方法不起作用!我不知道为什么?我在LOG中没有错误。但是第二种方法可行。

解决方案

哦,我没有

  Transport.send(message); 


I have App engine Application.

I have one servlet named push. I deploy me application and call my servlets GET method.

In My servlet, I have two methind:

1) first is that: (that method does not send mails. I dont undestand why? I have no errors)

void sendMail() throws UnsupportedEncodingException{

        Properties props = new Properties();
        Session session = Session.getDefaultInstance(props, null);
        String msgBody = "TEXT HERE";
        try {
            Message msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress("ownerMail","Example.com Admin"));
            msg.addRecipient(Message.RecipientType.TO, new InternetAddress("maria.chiamaia@gmail.com", "Mr. User"));
            msg.setSubject("YOUR PDF HAVE PROBLEMS");
            msg.setText(msgBody);

        } catch (AddressException e) {
            log("error", e);
        } catch (MessagingException e) {
            log("error", e);
        }

}

and I call another method too: (this works!)

void snedTest(){

String to = "somebody";
String from = "ownerMail";
String host = "localhost:8080";
Properties properties = System.getProperties();
properties.setProperty("mail.smtp.host", host);
Session session = Session.getDefaultInstance(properties);

try {

    MimeMessage message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));
    message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
    message.setSubject("This is the Subject Line!");
    message.setText("This is actual message");
    Transport.send(message);
    System.out.println("Sent message successfully....");
} catch (MessagingException mex) {
    mex.printStackTrace();
}

}

first method does not work! I don't know why? I have no error in LOG. But the second method works.

解决方案

OH, I did not have

 Transport.send(message);

这篇关于应用程序引擎邮件未发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆