smtplib_email邮件、itches微信和twilio短信

“我的所爱在闹市;
想去寻她人拥挤,
仰头无法泪沾耳。
爱人赠我双燕图;
回她什么:冰糖葫芦。
从此翻脸不理我,
不知何故兮使我胡涂。”

可是至少他还能见到他的女神,还得到了女神的赠送了不是?!我呐,我连女神的私人电子邮箱都拿不到!!!

如果有一天,我能得到女神的电子邮箱……

我就介样!!!
哦,更正一下,是女神们邮箱地址,那什么,是时候透漏我的女神们都是谁啦

拜跟我抢哈!!!

第一位:林美人、青霞、霞霞:

第二位:张曼玉、曼玉、曼曼:

第三位:王祖贤、小贤:

第四位:钟楚红、红红:

第五位:……算啦,先四位吧,写再多也没用,反正一个邮箱也拿不到

人类如果失去希望,世界将会变成怎样!

所以我们对未来还是要抱有希望哒!

要是有一天我真的拿到了她们的邮件地址,我就写一段代码,每天给美人们群发仰慕诗,表达我滔滔江水般滴崇拜!同时也可以假装跟美人们一起学习诗歌。

第一封信我会发送林徽因那首《你是人间的四月天》,因为我会背里面那句“你是一树一树的花开,是燕在梁间呢喃。你是爱是暖是希望,你是人间的四月天”

而且还不能让女神们发现我是群发邮件哒,女神都辣么骄傲,

我琢磨着邮件的格式应该这样:

亲爱的{美人昵称}:

   把网上找到那首人间四月天的诗放正文部分

仰慕你哒,
PythonABC

咋样?!我这梦做的美吧?

梦想还是要有的,万一成真了呢!

so先学会用python发邮件,然后在学用python群发邮件。这些技能备好了,没准啥时候就用上了泥

Python发送邮件:
 


Python群发个性化邮件:
 

import smtplib
#
fromAddr = This email address is being protected from spambots. You need JavaScript enabled to view it.'
toAddr = This email address is being protected from spambots. You need JavaScript enabled to view it.'


server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(fromAddr, "jkhgqkypgnrbmmyl")
#
header = 'To:' + toAddr + '\n' + 'From: ' + fromAddr + '\n' + 'Subject: testing \n'
msg = 'Your Message from Gmail!'
msg = header + msg

#
server.sendmail(fromAddr, toAddr, msg)
server.quit()


import smtplib
#
fromAddr = This email address is being protected from spambots. You need JavaScript enabled to view it.'
toAddr = This email address is being protected from spambots. You need JavaScript enabled to view it.'

server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.login(fromAddr, "jkhgqkypgnrbmmyl")
#
header = 'To:' + toAddr + '\n' + 'From: ' + fromAddr + '\n' + 'Subject: Gmail testing \n'
msg = 'Your Message from Gmail!'
msg = header + msg

#
server.sendmail(fromAddr, toAddr, msg)
server.quit()


import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
#
fromAddr = "This email address is being protected from spambots. You need JavaScript enabled to view it."
myPass = "jkhgqkypgnrbmmyl"
toAddr = "This email address is being protected from spambots. You need JavaScript enabled to view it."
#
msg = MIMEMultipart()
msg['From'] = fromAddr
msg['To'] = toAddr
msg['Subject'] = "Narcissistic Cannibal!"
#
body = '''
Don't wanna be sly and defile you
Desecrate my mind and rely on you
I just wanna break this crown
But it's hard when I'm so run down
And you're so cynical
Narcissistic cannibal
Got to bring myself back from the dead
'''
msg.attach(MIMEText(body, 'plain'))
# msg.attach(MIMEText(body))
#
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.login(fromAddr, myPass)
text = msg.as_string()
server.sendmail(fromAddr, toAddr, text)
# server.send_message(msg)
server.quit()

#https://docs.python.org/3.5/library/email-examples.html

import smtplib
#
from email.mime.multipart import MIMEMultipart
from email.mime.image import MIMEImage
from email.mime.text import MIMEText
#
fromAddr = "This email address is being protected from spambots. You need JavaScript enabled to view it."
myPass = "PythonABC2017"
toAddr = "This email address is being protected from spambots. You need JavaScript enabled to view it."

# create container email message
msg = MIMEMultipart()
msg['Subject'] = "Sunset"
msg['From'] = fromAddr
msg['To'] = toAddr
# msg.preamble = "When the sun has set, no candle can replace it."
body = "When the sun has set, no candle can replace it.\n\n\n"
#
msg.attach(MIMEText(body, 'plain'))
#
with open('sunset.jpg', 'rb') as fp:
	img = MIMEImage(fp.read())
#
msg.attach(img)
#
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(fromAddr, myPass)
#
server.send_message(msg)
#
server.quit()


#https://docs.python.org/3.5/library/email-examples.html

import smtplib
#
from email.mime.multipart import MIMEMultipart
from email.mime.image import MIMEImage
from email.mime.text import MIMEText
#
fromAddr = "This email address is being protected from spambots. You need JavaScript enabled to view it."
myPass = "jkhgqkypgnrbmmyl"
toAddr = "This email address is being protected from spambots. You need JavaScript enabled to view it."

# create container email message
msg = MIMEMultipart()
msg['Subject'] = "Sunset"
msg['From'] = fromAddr
msg['To'] = toAddr
# msg.preamble = "When the sun has set, no candle can replace it."
body = "When the sun has set, no candle can replace it.\n\n\n"
#
msg.attach(MIMEText(body, 'plain'))
#
with open('sunset.jpg', 'rb') as fp:
	img = MIMEImage(fp.read())
#
msg.attach(img)
#
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.login(fromAddr, myPass)
#
server.send_message(msg)

#
server.quit()



import smtplib

fromAddr = This email address is being protected from spambots. You need JavaScript enabled to view it.'
toAddr = This email address is being protected from spambots. You need JavaScript enabled to view it.'
msg = 'Your message from QQ'

username = This email address is being protected from spambots. You need JavaScript enabled to view it.'
pswd = 'jdfemszbepdfdhee'

server = smtplib.SMTP_SSL('smtp.qq.com', 465)
header = 'To:' + toAddr + '\n' + 'From: ' + fromAddr + '\n' + 'Subject: QQMail testing \n'
msg = header + msg

server.login(username, pswd)
server.sendmail(fromAddr, toAddr, msg)
server.quit()


import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

msg = MIMEMultipart()
msg['From'] = This email address is being protected from spambots. You need JavaScript enabled to view it.'
msg['To'] = This email address is being protected from spambots. You need JavaScript enabled to view it.'
msg['Subject'] = 'QQMail testing'

msg.attach(MIMEText('Your message from QQ'))

server = smtplib.SMTP_SSL('smtp.qq.com', 465)
server.login(This email address is being protected from spambots. You need JavaScript enabled to view it.', 'xuapwdrgxocnddec')
server.send_message(msg)
server.quit()

1 1 1 1 1 1 1 1 1 1 Rating 2.00 (3 Votes)