Hello , my friends today I will talk about sending emails through python. Let's get done! I expect you to know the basics about python.
First you have to import the library called "smtlib", You have it already installed.It goes with python installation. so how do you import that library? well you simply write at top of the script "import smtlib". When you've done that, you have to connect the mail server, you do that by writing (server = smtplib.SMTP'(smtp.gmail.com',587) ) so the first argument is just simply its IP address and the second one it's their port. Then you can go ahead and login to your gmail account (server.login([email protected], password) . As soon as you've done that you need to initiate an SSL connection to the mail server, in other words, you create a secure connection between the mail server and your computer( server.starttls())
. You can now send the email ( server.sendmail(YOUREMAIL, TOYOURFRIEND, "hi friend-the actuall text). As you can see here, you have three arguments the first one is your email second is the receiptor and the third one is simply the text. Before you save it you have to close the connect and log out. (server.logout()) (server.quit())
HOW THE SCRIPT LOOK:
import smtplib
server = smtplib.SMTP('smtp.gmai'l.com,587)
server.login(yourname,password)
server.starttls()
server.sendmail(YOUREMAIL, TOYOURFRIEND, "hi friend-the actuall text")
server.logout()
server.quit()
If you want to spam your friends you can always use while loop or for:
white True:
server.sendmail...
Congratulations @epiczed000! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!