如何从在“Google App Engine”上运行的Python脚本发送电子邮件? [英] How to send an e-mail from a Python script that is being run on "Google App Engine"?

查看:154
本文介绍了如何从在“Google App Engine”上运行的Python脚本发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从我的Python脚本发送电子邮件,该脚本正在 Google App Engines 到我的一个邮箱?

How could I send an e-mail from my Python script that is being run on "Google App Engines" to one of my mail boxes?

我只是一个初学者,我从来没有尝试从Python脚本发送消息。我发现这个脚本 (本指南)

I am just a beginner and I have never tried sending a message from a Python script. I have found this script (IN THIS TUTORIAL):

以下是与引用:

import sys, smtplib

fromaddr = raw_input("From: ")
toaddr = string.splitfields(raw_input("To: "), ',')
print "Enter message, end with ^D:"
msg = ''
while 1:
    line = sys.stdin.readline()
    if not line:
        break
    msg = msg + line

# The actual mail send
server = smtplib.SMTP('localhost')
server.sendmail(fromaddr, toaddrs, msg)
server.quit()






但我几乎不了解我可以从Google应用程序引擎:


but I hardly understand how I could have this script run from "Google App Engine":

1)首先,我不太明白什么电子邮件地址需要在 来自:

1) Firstly, I don't quite understand what e-mail address I need to place right after From: in this line:

fromaddr = raw_input("From: ")






<我可以在这里放置任何电子邮箱的电子邮件地址吗?


Can I just place here any e-mail address of any e-mail boxes that I have?

2)其次,让我们说我想发送一封邮件给我的这个电子邮件地址我的 brilliant@yahoo.com 。那么下一行,我猜这个方法必须这样看待:

2) Secondly, let's say I want to send a message to this e-mail address of mine brilliant@yahoo.com . Then the next line, I guess, must look this way:

toaddr = string.splitfields(raw_input("To: brilliant@yahoo.com"), ',')






这是对吗?


Is this right?

3)第三,让我们说,我想要的消息发送将是这句话:猫不能飞!然后,我猜,以 msg = 开头的行必须这样看待: p>




3) Thirdly, let's say, the message that I want to send will be this sentence: Cats cannot fly! Then, I guess, the line that starts with msg = must look this way:

msg = 'Cats cannot fly!'






这是否正确?


Is this correct?

4)如果将此脚本作为应用程序上传到GAE,则将该邮件发送到我的邮箱多久?它会发送这个消息给我一次,还是会发送给我每一秒钟,直到我删除应用程序? (这就是为什么我还没有尝试上传这个脚本到目前为止)

4) If I upload this script as an application to "GAE", how often will it be sending this message to my mail box? Will it send this message to me only once or it will be sending it to me every second all the time until I delete the application? (This is why I haven't tried uploading this script so far)

谢谢你所有的提前你的时间和耐心。

Thank You all in advance for Your time and patience.

推荐答案

当然 - 只需使用文档中所述的邮件API:

Sure - just use the Mail API as outlined in the docs:

  • Python
  • Java

这篇关于如何从在“Google App Engine”上运行的Python脚本发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆