接收电子邮件App Engine

时间:2014-12-29 09:37:00

标签: java google-app-engine

我的应用引擎应用程序存在邮件接收问题,我按照教程Google Cloud Platform进行了操作 https://cloud.google.com/appengine/docs/java/mail/receiving 但是我无法收到任何邮件。我收到的是一个空白页面。

应用服务引擎-web.xml中

<inbound-services>
  <service>mail</service>
</inbound-services>

的web.xml

 <servlet>
  <servlet-name>mailhandler</servlet-name>
  <servlet-class>MailHandlerServlet</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>mailhandler</servlet-name>
  <url-pattern>/_ah/mail/*</url-pattern>
</servlet-mapping>
<security-constraint>
  <web-resource-collection>
    <web-resource-name>mail</web-resource-name>
    <url-pattern>/_ah/mail/*</url-pattern>
  </web-resource-collection>
  <auth-constraint>
    <role-name>admin</role-name>
  </auth-constraint>
</security-constraint>

servlet ReceiveEmailServlet

public class MailHandlerServlet extends HttpServlet { 
    public void doPost(HttpServletRequest req, 
                       HttpServletResponse resp) 
            throws IOException { 
        Properties props = new Properties(); 
        Session session = Session.getDefaultInstance(props, null);
        MimeMessage message =  null;
        try {
            message = new MimeMessage(session, req.getInputStream());
        } catch (MessagingException e) {
            e.printStackTrace();
        }

        resp.setContentType("text/plain");
        resp.getWriter().println(message);
    }
}

1 个答案:

答案 0 :(得分:0)

<servlet-class>MailHandlerServlet</servlet-class>

使用完全限定的类名。 (例如,com.example.project.MailHandlerServlet