LoginSignup
5
5

More than 5 years have passed since last update.

メールの送信

Posted at

メールを送信するプログラムの備忘録

#メールを送信するプログラム
import smtplib

#SMTPサーバー名とポート番号の設定
smtp_obj = smtplib.SMTP('smtp.gmail.com', 587)
smtp_obj.ehlo()

#TLS暗号化の開始
smtp_obj.starttls()

#SMTPサーバにログインする
smtp_obj.login('ログイン名', 'パスワード')

#メールを送信する
smtp_obj.sendmail('送信者アドレス', '送信先アドレス', 'subject:タイトル\n本文')

#SMTPサーバーから切断
smtp_obj.quit()
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5