2016-02-05 63 views
0

我測試傳入的電子郵件URL在一個新的應用程序,並難倒他們爲什麼他們在開發服務器但在實時應用程序中工作。我的應用程序文件是:傳入電子郵件到App Engine實時應用程序被拒絕

的app.yaml:

version: 1 
runtime: python27 
api_version: 1 
threadsafe: true 

inbound_services: 
- mail 

handlers: 
- url: /.* 
    script: hello.app 
- url: /_ah/mail/.+ 
    script: hello.app 
    login: admin 

hello.py:

import logging 
import webapp2 
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler 

class MainPage(webapp2.RequestHandler): 
    def get(self): 
     self.response.headers['Content-Type'] = 'text/plain' 
     self.response.write('Hello, World!') 

class MailHandler(InboundMailHandler): 
    def receive(self, msg): 
     logging.info("Received a message from: %s, subject: %s", msg.sender, msg.subject) 

app = webapp2.WSGIApplication([ 
    ('/_ah/mail/', MailHandler), 
    ('/', MainPage), 
], debug=True) 

預期的日誌消息由開發服務器打印時,我 「送」 測試電子郵件使用但是當我發送電子郵件到實時應用程序(即[email protected])時,它會在日誌中記錄一個404,並返回一條退回消息,指出「傳遞給下列收件人永久失敗」 。有任何想法嗎?

回答

1

與我的工作程序部分比較你的代碼,一個區別是,我的應用程序確實

('/_ah/mail/.+', MailHandler), 

,而不是

('/_ah/mail/', MailHandler), 

確實,便利方法產生「/ _ah /mail/.+'

試試看。

更新後添加:另外一個區別。在我的app.yaml中,我最後匹配'/.*'。從表面上看,這似乎並不重要,但值得把最普通的模式放在最後以避免混淆,而不是匹配下面更具體的模式。

相關問題