2

我的应用程序允许用户发送消息。然后,消息的收件人可以将消息回复到地址 message_id@application_id.appspotmail.com。然后将消息发送给所有其他收件人而不进行修改。

这是使用的代码:

public class MailHandlerServlet extends HttpServlet { 
    /**
     * 
     */
    private static final long serialVersionUID = 7353232175365669L;
    static Logger log = Logger.getLogger(MailService.class.getName());

    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp) 
        throws IOException, ServletException { 
        Properties props = new Properties(); 
        Session session = Session.getDefaultInstance(props, null);
        //Parse the received email
        MimeMessage messageToSend = new MimeMessage(session, req.getInputStream());
        //Create the new message
        Message msg = new MimeMessage(messageToSend);
        //Add All Recipient to the new Message
        msg.addRecipient(Message.RecipientType.BCC, new InternetAddress(mail));
        //[...]
        //Set From to the last appengine email adresse
        msg.setFrom(new InternetAddress(req.getPathInfo(), "Mail"));
        //Send the email
        Transport.send(msg);
    }
}

此代码适用于许多电子邮件,但对于某些电子邮件,有一个错误:

/_ah/mail/5e3698a24927925e9f32cf0050aef84a@[...].appspotmail.com
javax.mail.SendFailedException: Send failure (javax.mail.MessagingException: Converting     attachment data failed)
    at javax.mail.Transport.send(Transport.java:163)
    at javax.mail.Transport.send(Transport.java:48)
    at [...].server.mail.MailHandlerServlet.doPost(MailHandlerServlet.java:178)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at cef.kephas.server.NamespaceFilter.doFilter(NamespaceFilter.java:31)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:57)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:266)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:447)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:466)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:473)
    at com.google.tracing.TraceContext.runInContext(TraceContext.java:694)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:338)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:330)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:470)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
    at java.lang.Thread.run(Thread.java:679)
Caused by: javax.mail.MessagingException: Converting attachment data failed
    at com.google.appengine.api.mail.stdimpl.GMTransport.sendMessage(GMTransport.java:215)
    at javax.mail.Transport.send(Transport.java:95)
    ... 38 more  

问题是什么?我不更改消息。那些不起作用的消息不是我发的,所以我没有消息中包含的手段。是否有人设法提供这样的服务?

谢谢。

4

0 回答 0