Friday 27 September 2013

send fake email using python smtplib library


Hi All,

Today we will learn how can we send a fake email from any email account using python .

we are using python library smtplib which will call machine's smtp server and it will send email from provided From email .
While using ubuntu you can use postfix as smtp server .


import smtplib
To ="91prashantgaur@gmail.com"
Subject = "Test Fake Email "
Message  = "Hi How are you  ?"
Email = 'test@gmail.com'            # from this email id we will send email 
server = smtplib.SMTP('localhost')        # local smtp server of machine
Message = string.join(("From: %s" % Email,
                                   "To: %s" % To,
                                   "Subject: %s" % Subject,
                                  "",
                                  Message
                                  ),"\r\n")
server.sendmail(Email , [To], Message)
server.quit()

If any question let me know at  91prashantgaur@gmail.com


Prashant Gaur
Python/JavaScript Developer
9717353657