Failed to send email on Google engine

I am tired of using Javamail to send email. But I got the following message

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

I tried to send an email from the administrator (the account I’m downloading), or the user I’m logging into the application. (off UserService - getCurrentUser().getEmail()) Both refused

I wonder if there is any special setting I have to set

    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 = "my_admin_account@gmail.com";
    msg.setFrom(new InternetAddress(email));
    msg.addRecipient(Message.RecipientType.TO,
                     new InternetAddress("some_test_email@gmail.com"));
    msg.setSubject("Test Email");
    msg.setText("Nobody");
    Transport.send(msg);

Advise thanks Roy

+5
source share
5 answers

This is really very strange. I just wrote the following example:

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 = "my_admin_account@gmail.com";
    msg.setFrom(new InternetAddress(email));
    msg.addRecipient(Message.RecipientType.TO,
                     new InternetAddress("jesse.sightler@gmail.com"));
    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>");
}

There were no exceptions, and I received an email. Are you sure that the real application is no longer happening?

+5
source

:

Google , . " " , .

, " " , , ​​ , , .

, .

+4

! , , .

+1

, , . -, . * , - * .

+1

, , , , .

, , . , Google App Engine .

0

All Articles