views:

85

answers:

1

I am writing an App Engine app that is supposed to receive emails in this form: [email protected] (someID is an alphanumeric ID that I generate).

I have this in my web.xml thinking it would catch emails that start with 'addcontact.':

  <servlet> 
    <servlet-name>addNewContactServlet</servlet-name> 
    <servlet-class>com.mycompany.server.AddNewContactServlet</servlet- 
class> 
  </servlet> 
  <servlet-mapping> 
    <servlet-name>addNewContactServlet</servlet-name> 
    <url-pattern>/_ah/mail/addcontact.*</url-pattern> 
  </servlet-mapping> 

However, both on my dev machine and on google's servers email is not received. On the dev machine I get this message (I get a similar error in the deployed log)

Message send failure HTTP ERROR 404 Problem accessing /_ah/mail/ [email protected]. Reason: NOT_FOUND

I can receive email at fully specified addresses or when I use /_ah/mail/* The google documentation made me believe it was possible to include partial email addresses in web.xml. Am I not using the wildcard correctly? Does the period have something to do with it? Can this be done somehow?

The reason why I think it should work is the google docs at: http://code.google.com/appengine/docs/java/mail/receiving.html

In it there is this example web.xml file:

<servlet>
  <servlet-name>handleowner</servlet-name>
  <servlet-class>HandleOwner</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>handleowner</servlet-name>
  <url-pattern>/_ah/mail/owner*</url-pattern>
</servlet-mapping>
<servlet>
  <servlet-name>handlesupport</servlet-name>
  <servlet-class>HandleSupport</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>handleowner</servlet-name>
  <url-pattern>/_ah/mail/support*</url-pattern>
</servlet-mapping>
<servlet>
  <servlet-name>catchallhandler</servlet-name>
  <servlet-class>MailCatchallServlet</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>catchallhandler</servlet-name>
  <url-pattern>/_ah/mail/*</url-pattern>
</servlet-mapping>
<security-constraint>
  <web-resource-collection>
    <url-pattern>/_ah/mail/*</url-pattern>
  </web-resource-collection>
  <auth-constraint>
    <role-name>admin</role-name>
  </auth-constraint>
</security-constraint>

It looks like the support and owner email addresses are wildcarded to match any that begin with that address.

A: 

This should work. Are you sure it's not your handler returning the 404? I would suggest trying a couple of things to figure out the source of the problem:

  1. Set up a catchall handler for /_ah/mail/* and check that works
  2. If it does, set up one for a simpler prefix, or exact address.
Nick Johnson
The catchall handler for /_ah/mail/* has always worked. Whenever I change that line in web.xml to include a wildcard it does not work. On my dev machine using the debugger the servlet is never entered, just the same error message.Using my dev machine I simulated an incoming email with the 'to' address of, literally, addcontact.* (a literal match for what's in my web.xml) and the servlet was invoked. Still confused...
Mark M