开发者

Setting up App Engine to receive email addresses with ids in the address

I am writing an App Engine app that is supposed to receive emails in this form: addcontact.someID@my-app.appspotmail.com (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/ addcontact.z1vnq3p2bvtfsuzbxg13sfon@myapp.appspotmail.com. 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</ser开发者_JAVA百科vlet-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.


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜