2011-12-24 48 views
1

有人知道我的程序有什麼問題嗎? 我寫了一個main.py.並將其發佈到GAE。 但是當我在GAE上鍵入一些文字,它不能在表GAE(python)如何接收郵件並在留言板上發帖然後發送郵件給所有用戶?


    class Send(webapp.RequestHandler):   
     def send(self): 

      mail.send_mail(sender=users.get_current_user(), 
          to=Greeting.author.all(),#Table 
          body=self.request.get('content')) 

      self.redirect("/") 

    application = webapp.WSGIApplication([ 
     ('/', MainPage), 
     ('/sign', Guestbook),##click sign to use Guestbook 
     ('/sign', Send) 
    ], debug=True) 

發送郵件到作者和我寫一個handle_incoming_email.py 嘗試將郵件發送到123 @ HTTP:appid.appspotmail .COM 但我不能看到表中的任何事情,不能發送郵件到作者在表


    class ReceiveEmail(InboundMailHandler): 
     def receive(self,message): 
      logging.info("Received email from %s" % message.sender) 
      plaintext = message.bodies(content_type='text/plain') 

      mail.send_mail(sender=mail_message.sender, 
           to=m.Greeting.author.all(), 
          body=plaintext) 

    application = webapp.WSGIApplication([ 
     ReceiveEmail.mapping() 
    ], debug=True) 
+1

我推薦閱讀Python入門指南(http://code.google.com/appengine/docs/python/gettingstarted/),它有一個簡單的留言板演示。然後閱讀郵件API概述(http://code.google.com/appengine/docs/python/mail/)。 –

回答

2

對於recieving電子郵件看到http://code.google.com/appengine/docs/python/mail/receivingmail.html

發送電子郵件看到http://code.google.com/appengine/docs/python/mail/sendingmail.html

例如

import logging, email 
from google.appengine.ext import webapp 
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler 
from google.appengine.ext.webapp.util import run_wsgi_app 
from google.appengine.api import mail 

class LogSenderHandler(InboundMailHandler): 
    def receive(self, mail_message): 
     # post it to message board 
     # assuming Message is a table 
     text = "\n".join(mail_message.bodies('text/plain')) 
     msg = Message(text=text, sender=mail_message.sender) 
     msg.put() 

     # email msg to list of users 
     mail.send_mail(sender=mail_message.sender, to=[list of user], body=text) 
相關問題