2

我已将 appengine 设置为允许传入邮件,如果我的 web.xml 文件包含

    <servlet>
    <servlet-name>mailhandler</servlet-name>
    <servlet-class>VerifyReply</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>mailhandler</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>

它可以工作并运行 VerifyReply servlet,但如果我想将传入的电子邮件限制为仅发送到 verifyreply@... 的电子邮件地址(请注意 url 模式与上述不同)

    <servlet>
    <servlet-name>mailhandler</servlet-name>
    <servlet-class>VerifyReply</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>mailhandler</servlet-name>
    <url-pattern>/_ah/mail/v*</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>

它停止工作,我收到一封退回给发件人的电子邮件。我的日志页面显示服务器运行 /_ah/mail/verifyreply@... 但它不运行 servlet 并退回电子邮件。

任何想法,我想我都在遵循https://developers.google.com/appengine/docs/java/mail/receiving上的指南

4

1 回答 1

0

根据文档,不支持过滤地址:

When App Engine moved to a standard Java Web Server, the ability to specify richer matching patterns was lost (e.g. one used to be able to specify a url-pattern like /_ah/mail/support*). If such pattern matching is desired, consider using a filter-based approach based on the following code snippets.

它会认为它是一个错误,指定完整地址确实有效。该页面包含有关如何在邮件处理程序过滤器(servlet 意义上的过滤器)中进行地址匹配的示例。如果您不想接受该消息,您应该匹配那里的地址并返回 404。或者,如果您不关心退回邮件,则可以忽略不想要的邮件。

于 2013-04-10T13:48:47.640 回答