Created
October 26, 2016 01:29
-
-
Save phero/354b27463b5506d6a5f7b2b9ee0b8b7a to your computer and use it in GitHub Desktop.
メールが送信できることを確認するためのPythonスクリプト。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from email.mime.text import MIMEText | |
import smtplib | |
EMAIL = '送信元メールアドレス' | |
PASSWORD = 'アプリパスワード' | |
TO = '送信先メールアドレス' | |
msg = MIMEText('This is a test') | |
msg['Subject'] = 'Test Mail Subject' | |
msg['From'] = EMAIL | |
msg['To'] = TO | |
s = smtplib.SMTP(host='smtp.gmail.com', port=587) | |
s.starttls() | |
s.login(EMAIL, PASSWORD) | |
s.sendmail(EMAIL, TO, msg.as_string()) | |
s.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment