gpt4 book ai didi

python - GAE(python)如何需要接收邮件并在留言板上发布然后向所有用户发送邮件?

转载 作者:行者123 更新时间:2023-12-01 06:04:49 24 4
gpt4 key购买 nike

有人知道我的程序出了什么问题吗?我写了一个main.py。并将其启动到 GAE。但是当我在GAE上键入一些单词时,它无法向表中的作者发送邮件

 
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)

最佳答案

要接收电子邮件,请参阅 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)

关于python - GAE(python)如何需要接收邮件并在留言板上发布然后向所有用户发送邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8626331/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com