在应用程序发明者中使用 Shival wolfs WolfWebEmail2 通过 Google 应用程序引擎发送邮件,但收件人电子邮件中没有任何内容。
需要确认我的代码是否正确。
没有在应用引擎上显示任何错误。
这对于运行 webapp 的命令看起来是否正确?
application = webapp.WSGIApplication([('/', MainPage), ('/sendemail', sendemail), ('/attach', attachfile)], debug=True)
def main():
run_wsgi_app(application)
想想我有点小键盘大手指综合症。
提前谢谢了。
好的齐格。非常感谢。这里是
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)
我希望就是这样!对此很陌生。