Strange problem with Google App Engine Java Mail

Posted by Velu on Stack Overflow See other posts from Stack Overflow or by Velu
Published on 2010-09-23T08:48:56Z Indexed on 2010/12/24 13:54 UTC
Read the original article Hit count: 263

Filed under:

Hi,

I'm using the MailService feature of Google App Engine in my application. It works fine in one application without any issues. But the same code doesn't work in another app. I'm not able to figure it out. Please help. Following is the piece of code that I use to send 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()); 
                } 
        } 

When I look at the log (on the server admin console), it prints the statement "content is set ..." and after that there is nothing in the log. The mail is not sent. At times I get the following error after the above statement is printed (and the mail is not sent).

com.google.appengine.repackaged.com.google.common.base.internal.Finalizer getInheritableThreadLocalsField: Couldn't access Thread.inheritableThreadLocals. Reference finalizer threads will inherit thread local values.

But the mail quota usage keeps increasing.

Remember, this works fine in one application, but not in other. I'm using the same set of email addresses in both the apps (for from and to).

I'm really stuck with this. Appreciate any help.

Thank you. Velu

© Stack Overflow or respective owner

Related posts about google-app-engine