在应用程序发明人中使用Shival wolfs WolfWebEmail2通过Google应用引擎发送邮件,并且没有任何内容到达收件人电子邮件。
需要确认我的代码是否正确。
未在应用引擎上显示任何错误。
对于运行webapp的命令,这看起来是否正确?
application = webapp.WSGIApplication([('/', MainPage), ('/sendemail', sendemail), ('/attach', attachfile)], debug=True)
def main():
run_wsgi_app(application)
想想我有一点小键盘大手指综合症。
非常感谢提前。
OK Zig。非常感谢。这是
class sendemail(webapp.RequestHandler):
def process_email(self, data):
outvalue=""
ValidData = False
logging.info("data: %s" %data)
details=data.split("|||")
data = "\"%s\"" %data
if len(details) == 5 or len(details) == 7:
message = mail.EmailMessage()
message.sender = EmailFrom
NewAuthKey = details[0]
EmailTo = details[1]
EmailSubject = details[2]
EmailBody = details[3]
EmailBody = EmailBody.replace("\\t","\t")
if details[4].lower()=="yes" and len(details) == 7:
filename=details[5];
file_id=details[6];
ValidData = True
if ValidData:
if NewAuthKey == AuthKey:
logging.info("Auth Key Valid")
else:
logging.info("Auth Key does not Match")
outvalue = "Auth Key is Invalid"
ValidData = False
if ValidData:
if mail.is_email_valid(EmailTo):
message.to = EmailTo
else:
logging.info("Email Address for TO Address is Invalid")
outvalue = "Email Address for TO Address is Invalid"
ValidData = False
if ValidData:
if len(EmailBody) > 0 and len(EmailSubject) > 0:
message.subject = EmailSubject
message.body = EmailBody
else:
logging.info("Subject or Body was Empty")
outvalue = "Subject or Body was left Empty"
ValidData = False
if ValidData:
if details[4].lower()=="yes":
try:
filedata = db.GqlQuery("SELECT * FROM emailattach WHERE id = :1 LIMIT 1",file_id).get()
if filedata:
message.attachments = [(filename, filedata.blob)]
except Exception, message:
ValidData = False
logging.info("Could not attach file:\n\n "+str(message))
outvalue = "Could not attach file:\n\n "+str(message)
if ValidData:
try:
message.send()
logging.info("Email Sent")
outvalue = "Email Sent"
if details[4].lower()=="yes": ##delete the file once emailed
key = db.GqlQuery("SELECT __key__ FROM emailattach where id = :1", file_id).get()
if key:
db.run_in_transaction(dbSafeDelete,key)
except Exception, message:
logging.info(message)
outvalue = str(message)
self.response.out.write(outvalue)
我希望如此!对此不熟悉。
答案 0 :(得分:0)
你遗漏了boiplerplate的最后一部分:
if __name__ == '__main__':
main()
没有它,将不会处理对每个实例的第一个请求。
答案 1 :(得分:0)
你能告诉我们sendemail的功能吗?
修改强>
message.sender = EmailFrom
EmailFrom在哪里?
尝试删除所有验证并检查电子邮件是否已发送。
首先尝试运行它 -
message = mail.EmailMessage(sender="you@domain.com",
subject="Testing")
message.to = "you@domain.com"
message.body = "This is the body!"
message.send()
将这两个电子邮件地址更改为您的电子邮件。
如果有效,则一次检查一次验证和其他部分。