Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #! /usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import smtplib
  4. from email.mime.text import MIMEText
  5.  
  6. def sendGmail(to, sub, body):
  7. username = "送信アドレス"
  8. msg = MIMEText(body)
  9. msg['Subject'] = sub
  10. msg['From'] = username
  11. msg['To'] = to
  12. smtp = smtplib.SMTP()
  13. smtp.connect()
  14. smtp.sendmail(username, to, msg.as_string())
  15. smtp.close()
  16. if __name__ == '__main__':
  17. to = '宛先'
  18. sub = 'Python smtplib'
  19. body = 'Hello, Python'
  20. sendGmail(to, sub, body)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement