2
我使用Python在Google App Engine中編寫表單,用戶可以輸入數據以形成表單。輸入後,我希望將這些數據發送到您的電子郵件。例如:[email protected]。Python:將表單數據發送到一個電子郵件地址
我的問題是:在Python中,它是否具有簡單的功能(我可以在Google App Engine上使用此功能)發送電子郵件?
謝謝:)
我使用Python在Google App Engine中編寫表單,用戶可以輸入數據以形成表單。輸入後,我希望將這些數據發送到您的電子郵件。例如:[email protected]。Python:將表單數據發送到一個電子郵件地址
我的問題是:在Python中,它是否具有簡單的功能(我可以在Google App Engine上使用此功能)發送電子郵件?
謝謝:)
Python確實有用於傳輸電子郵件的郵件包。
包括以下是一個例子如在Python docs
# Import smtplib for the actual sending function
import smtplib
# Import the email modules we'll need
from email.mime.text import MIMEText
# Open a plain text file for reading. For this example, assume that
# the text file contains only ASCII characters.
fp = open(textfile, 'rb')
# Create a text/plain message
msg = MIMEText(fp.read())
fp.close()
# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = 'The contents of %s' % textfile
msg['From'] = me
msg['To'] = you
# Send the message via our own SMTP server, but don't include the
# envelope header.
s = smtplib.SMTP('localhost')
s.sendmail(me, [you], msg.as_string())
s.quit()
另外發現,該應用發動機具有mail API爲好。
from google.appengine.api import mail
mail.send_mail(sender="Example.com Support <[email protected]>",
to="Albert Johnson <[email protected]>",
subject="Your account has been approved",
body="""
Dear Albert:
Your example.com account has been approved. You can now visit
http://www.example.com/ and sign in using your Google Account to
access new features.
Please let us know if you have any questions.
The example.com Team
""")