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()
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()
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
In [110]:
print li
In [111]:
emailist = list(li)
In [112]:
print emailist
In [117]:
print emailist.sort()
In [114]:
i.close('emz')
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())
In [ ]: