Created
June 27, 2019 08:21
-
-
Save kizashi1122/66a18757212ef6a8036e580acb48de0c to your computer and use it in GitHub Desktop.
This file contains 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
# https://www.python.ambitious-engineer.com/archives/2034 | |
import smtplib | |
from email.mime.text import MIMEText | |
# 送受信先 | |
to_email = "xxxxx@gmail.com" | |
from_email = "xxxxx@s3.spaaqs.ne.jp" | |
# MIMETextを作成 | |
message = "メール本文" | |
msg = MIMEText(message, "html") | |
msg["Subject"] = "mail from python" | |
msg["To"] = to_email | |
msg["From"] = from_email | |
# サーバを指定する1 | |
host = 'ingage.sakura.ne.jp' | |
port = 587 | |
user = "userid here" | |
password = 'password here' | |
# サーバを指定する2 | |
#host = 'smtp.spaaqs.ne.jp' | |
#port = 587 | |
#user = "userid here" | |
#password = 'password here' | |
server = smtplib.SMTP(host, port) | |
if server.has_extn('STARTTLS'): | |
server.starttls() | |
server.set_debuglevel(True) | |
server.login(user, password) | |
# メールを送信する | |
server.send_message(msg) | |
# 閉じる | |
server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment