gmail sender [python script]
#1
Memang seh dah banyak tools gmail sender yang berhamburan di dunia maya !! karena ane pikir lebih enak coba buat sendiri jadi yahh di coba aja deh, sekalian melanjutkan pelajaran bahasa pemrograman yg satu ini. yup python !

berikut scriptnya !
Code:
#!/usr/bin/env python
import smtplib
import os, sys
from email import Encoders
from email.MIMEBase import MIMEBase
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
import getpass

os.system('clear')
print '''
                       _ _
  __ _ _ __ ___   __ _(_) |
/ _` | '_ ` _ \ / _` | | |
| (_| | | | | | | (_| | | |
\__, |_| |_| |_|\__,_|_|_| SENDER
|___/                    
_____________________________________
                            by. RR12

'''
print '===========   LOGIN WITH GMAIL.com   ============='
email=raw_input('Your Gmail address    : ')
email_pass=getpass.getpass('Your account password    :')
print 'Connecting to gmail.com ...'
try:
    mailserver=smtplib.SMTP("smtp.gmail.com",587)
    mailserver.ehlo()
    mailserver.starttls()
    mailserver.ehlo()
    mailserver.login(email,email_pass)
    print 'Connected to gmail.com !'
except:
    print 'Failed connecting to gmail.com !'
    sys.exit()

kirim='y'

while kirim=='y':
    target=raw_input('Your email target        : ')
    print '==============================================='
    subjek=raw_input('[+] Subject                 : ')
    pesan=raw_input('[+] Message body            : ')
    attach=raw_input('[+] Your attachment file path   : ')
    print '==============================================='
    
    msg=MIMEMultipart()
    msg['From']=email
    msg['to']=target
    msg['Subject']=subjek
    msg.attach(MIMEText(pesan))
    if (attach!=''):
        rr=MIMEBase('application', 'octet-stream')
        rr.set_payload(open(attach, 'rb').read())
        Encoders.encode_base64(rr)
        rr.add_header('Content-Disposition', 'attachment; filename="%s"' %os.path.basename(attach))
        msg.attach(rr)
    
    try:
        mailserver.sendmail(email,target,msg.as_string())
        print 'Email have sent successfully to %s' %(target)
            
    except:
        print 'Email was failed to sent to %s' %(target)
        sys.exit()
        
    kirim=raw_input('[+] You want to sent more : [y/n] ')
print 'Thanks for use this simple program !!'

berikut SSnya dan cara penggunaannya !!
[Image: 98shop.jpg]

hope it's will be usefull for all of you bro !! Big Grin


Messages In This Thread
gmail sender [python script] - by u5h4nt - 08-22-2011, 02:03 AM
RE: gmail sender [python script] - by iKONspirasi - 08-22-2011, 02:35 AM
RE: gmail sender [python script] - by u5h4nt - 08-22-2011, 05:22 AM
RE: gmail sender [python script] - by THJC - 08-22-2011, 06:18 AM
RE: gmail sender [python script] - by wahyuardan - 08-02-2013, 03:00 PM




Users browsing this thread: 2 Guest(s)