app engine mail is not sending

青春壹個敷衍的年華 提交于 2019-12-11 19:46:26

问题


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.


回答1:


OH, I did not have

 Transport.send(message);


来源:https://stackoverflow.com/questions/19291429/app-engine-mail-is-not-sending

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!