Я работаю с документами здесь:
http://code.google.com/appengine/docs/java/mail/overview.html#Receiving_Mail_in_Java
Для получения электронной почты. Ниже мой сервлет:
package mailserver;
import java.io.IOException;
import java.util.Properties;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.internet.MimeMessage;
import javax.servlet.http.*;
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);
}
}
Мой appengine-xml:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>myapp</application>
<version>4</version>
<inbound-services>
<service>mail</service>
</inbound-services>
<!--
By default, App Engine sends requests serially to a given web server.
To allow App Engine to send multiple requests in parallel specify:
<threadsafe>true</threadsafe>
-->
<!-- Configure java.util.logging -->
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
</appengine-web-app>
И web.xml
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>MailHandlerServlet</servlet-name>
<servlet-class>mailserver.MailHandlerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MailHandlerServlet</servlet-name>
<url-pattern>/_ah/mail/notification@myemail.appspotmail.com</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<url-pattern>/_ah/mail/notification@myemail.appspotmail.com</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
</web-app>
Мой первый вопрос, я не настроил никакого дополнительного адреса электронной почты, на котором написано:
Получать входящие письма на адреса string@appid.appspotmail.com
Полагаю, это как ловушка, а строка может быть чем угодно?
Мой следующий вопрос: будет ли сервлет показывать что-нибудь, если он работает? На данный момент я просто получаю The requested URL /mailserver was not found on this server.
Любая помощь, с которой можно начать, была бы великолепна.
1024 * ТИА *