Skip to content

Instantly share code, notes, and snippets.

@kizashi1122
Created June 27, 2019 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kizashi1122/66a18757212ef6a8036e580acb48de0c to your computer and use it in GitHub Desktop.
Save kizashi1122/66a18757212ef6a8036e580acb48de0c to your computer and use it in GitHub Desktop.
# 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