In [76]:
import email
import smtplib

In [77]:
from email.mime.text import MIMEText

In [78]:
lic = open('LICENSE', 'rb')

In [79]:
msg = MIMEText(lic.read())

In [80]:
lic.close()

In [81]:
msg['Subject'] = 'The contents of %s' % msg

In [82]:
msg['From'] = ('will@artcontrol.me')

In [83]:
msg['To'] = ('peter@brobeur.com')

In [84]:
s = smtplib.SMTP('localhost')

In [85]:
s.sendmail('will@artcontrol.me', [you], msg.as_string())
s.quit()


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-85-f946c07f4d44> in <module>()
----> 1 s.sendmail('will@artcontrol.me', [you], msg.as_string())
      2 s.quit()

NameError: name 'you' is not defined

In [86]:
ps = open('ps', 'r')

In [87]:
passW = ps.readline()

In [87]:


In [87]:


In [88]:
#!/usr/bin/python -tt

from email.mime.text import MIMEText
from datetime import date
import smtplib

SMTP_SERVER = ("smtpout.secureserver.net")
SMTP_PORT = 80
SMTP_USERNAME = ("will@artcontrol.me")
SMTP_PASSWORD = passW

EMAIL_TO = (["peter@brobeur.com"])
EMAIL_FROM = ("will@gmail.com")
EMAIL_SUBJECT = ("Demo Email : ")

DATE_FORMAT = ("%d/%m/%Y")
EMAIL_SPACE = (", ")

DATA=('This is the content of the email.')

def send_email():
    msg = MIMEText(DATA)
    msg['Subject'] = EMAIL_SUBJECT + (" %s") % (date.today().strftime(DATE_FORMAT))
    msg['To'] = EMAIL_SPACE.join(EMAIL_TO)
    msg['From'] = EMAIL_FROM
    mail = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
    mail.starttls()
    mail.login(SMTP_USERNAME, SMTP_PASSWORD)
    mail.sendmail(EMAIL_FROM, EMAIL_TO, msg.as_string())
    mail.quit()

if __name__=='__main__':
    send_email()


---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-88-b0d48821a7aa> in <module>()
     31 
     32 if __name__=='__main__':
---> 33     send_email()

<ipython-input-88-b0d48821a7aa> in send_email()
     24     msg['To'] = EMAIL_SPACE.join(EMAIL_TO)
     25     msg['From'] = EMAIL_FROM
---> 26     mail = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
     27     mail.starttls()
     28     mail.login(SMTP_USERNAME, SMTP_PASSWORD)

/usr/lib64/python2.7/smtplib.pyc in __init__(self, host, port, local_hostname, timeout)
    248         self.esmtp_features = {}
    249         if host:
--> 250             (code, msg) = self.connect(host, port)
    251             if code != 220:
    252                 raise SMTPConnectError(code, msg)

/usr/lib64/python2.7/smtplib.pyc in connect(self, host, port)
    309             print>>stderr, 'connect:', (host, port)
    310         self.sock = self._get_socket(host, port, self.timeout)
--> 311         (code, msg) = self.getreply()
    312         if self.debuglevel > 0:
    313             print>>stderr, "connect:", msg

/usr/lib64/python2.7/smtplib.pyc in getreply(self)
    353         while 1:
    354             try:
--> 355                 line = self.file.readline()
    356             except socket.error as e:
    357                 self.close()

/usr/lib64/python2.7/socket.pyc in readline(self, size)
    445             while True:
    446                 try:
--> 447                     data = self._sock.recv(self._rbufsize)
    448                 except error, e:
    449                     if e.args[0] == EINTR:

KeyboardInterrupt: 

In [ ]:
import string
import sys
from email.MIMEText import MIMEText

In [ ]:
readfile = 'README.md'
f = file(readfile)
attach = MIMEText(f.read())
attach.add_header('Content-Disosition', 'attachment', filename=readfile)

In [ ]:
import smtplib  
      
fromz = 'hamnmersmake@gmail.com'  
toz = 'will@artcontrol.me'  
msg = 'Peter is drinking tea! '  
      
      
# Credentials (if needed)  
username = 'hammersmake@gmail.com'
password = passW   
# The actual mail send  
server = smtplib.SMTP('smtp.gmail.com:587')  
server.starttls()  
server.login(username,password)  
server.sendmail(fromz, toz, msg)

In [ ]:
subject = ('Good Morning!')

In [ ]:
nums = 1

In [ ]:
for nums in range(2):
    import smtplib  
      
    fromz = 'hamnmersmake@gmail.com'  
    toz = 'will@artcontrol.me'  
    msg = 'Fez is sitting on couch!'  
      
      
    # Credentials (if needed)  
    username = 'hammersmake@gmail.com'
    password = passW   
    # The actual mail send  
    server = smtplib.SMTP('smtp.gmail.com:587')  
    server.starttls()  
    server.login(username,password)  
    server.sendmail(fromz, toz, msg)

In [105]:
li = [i.strip().split() for i in open("emz").readlines()]

In [106]:
newListz = []

In [107]:
print newListz


[]

In [108]:
newListz.append(li)

In [109]:
print newListz


[[["['hammersmake@gmail.com',", "'will@artcontrol.me',", "'peter@brobeur.com']"]]]

In [110]:
print li


[["['hammersmake@gmail.com',", "'will@artcontrol.me',", "'peter@brobeur.com']"]]

In [111]:
emailist = list(li)

In [112]:
print emailist


[["['hammersmake@gmail.com',", "'will@artcontrol.me',", "'peter@brobeur.com']"]]

In [117]:
print emailist.sort()


None

In [114]:
i.close('emz')


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-114-b4d0b653c29a> in <module>()
----> 1 i.close('emz')

AttributeError: 'str' object has no attribute 'close'

In [27]:
body = ('This is all the text in the world!')

In [28]:
emilz = string.join((
    'From %s' % fromz,
    'To: %s' % toz, 
    'Subject: %s' % subject,
    "",
    body), '\r\n')

In [29]:
server = smtplib.SMTP('smtp.gmail.com:587')  
server.starttls()  
server.login(username,password)  
server.sendmail(fromz, [toz], emilz)


Out[29]:
{}

In [37]:
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from smtplib import SMTP
 
msg = MIMEMultipart()
msg['Subject'] = ('Email From Python jajaja')
msg['From'] = ('hammersmake@gmail.com')
msg['To'] = ('hammersmake@gmail.com')
 
# That is what u see if dont have an email reader:
msg.preamble = 'Multipart massage.\n'
 
# This is the textual part:
part = MIMEText("Hello im sending an email from a python program")
msg.attach(part)
 
# This is the binary part(The Attachment):
part = MIMEApplication(open("README.md","rb").read())
part.add_header('Content-Disposition', 'attachment', filename="README.md")
msg.attach(part)
 
# Create an instance in SMTP server
smtp = SMTP("smtp.gmail.com:587")
# Start the server:
smtp.login("hammersmake@gmail.com", passW)
# Send the email
smtp.sendmail(msg['From'], msg['To'], msg.as_string())


---------------------------------------------------------------------------
SMTPException                             Traceback (most recent call last)
<ipython-input-37-5c49231bf2e9> in <module>()
     24 smtp = SMTP("smtp.gmail.com:587")
     25 # Start the server:
---> 26 smtp.login("hammersmake@gmail.com", passW)
     27 # Send the email
     28 smtp.sendmail(msg['From'], msg['To'], msg.as_string())

/usr/lib64/python2.7/smtplib.pyc in login(self, user, password)
    575 
    576         if not self.has_extn("auth"):
--> 577             raise SMTPException("SMTP AUTH extension not supported by server.")
    578 
    579         # Authentication methods the server supports:

SMTPException: SMTP AUTH extension not supported by server.

In [ ]: