#!/usr/bin/env python
# Gmail SMTP script by joon
# Snippets from the following codes were used:
# http://www.go4expert.com/forums/showthread.php?t=7567
# http://docs.python.org/library/email-examples.html?highlight=sendmail
# http://djkaos.wordpress.com/2009/04/08/python-gmail-smtp-send-email-script/
import smtplib
from email.mime.text import MIMEText
sender = 'sender@gmail.com'
recipients = 'toEmailAddress'
msg = MIMEText('Email Contents')
msg['Subject'] = 'Email Subject'
msg['From'] = sender
msg['To'] = recipients
smtpserver = 'smtp.gmail.com'
smtpuser = 'ID' # set SMTP username here
smtppass = 'Password' # set SMTP password here
session = smtplib.SMTP("smtp.gmail.com", 587)
session.ehlo()
session.starttls()
session.ehlo()
session.login(smtpuser, smtppass)
smtpresult = session.sendmail(sender, [recipients], msg.as_string())
if smtpresult:
  errstr = ""
  for recip in smtpresult.keys():
      errstr = """Could not delivery mail to: %s
Server said: %s
%s
%s""" % (recip, smtpresult[recip][0], smtpresult[recip][1], errstr)
  raise smtplib.SMTPException, errstr
session.close()
[출처] https://gist.github.com/840116#file_gmailsmtp.py



[주의] 본 자료는 연구용 및 학습자료로 사용하길 바라며, 악의적인 사용시 
사용자 본인에게 책임이 있음을 명시합니다.



'Hello_World! > 애플추가_파이썬' 카테고리의 다른 글

파이썬 v2.7.2 - email: Examples  (0) 2011.10.05
Python - Sending Email using SMTP  (0) 2011.10.05
Web Shell Detection Using NeoPI  (0) 2011.09.01
[md5 cracker] icrack  (0) 2011.09.01
[자작쉘] http URL 긁어오기  (0) 2011.08.08
Posted by bitfox
l