Skip to content

Instantly share code, notes, and snippets.

@PANDATD
Last active October 24, 2020 05:20
Show Gist options
  • Select an option

  • Save PANDATD/4f7df02555dd965d8c930e7ea67e39af to your computer and use it in GitHub Desktop.

Select an option

Save PANDATD/4f7df02555dd965d8c930e7ea67e39af to your computer and use it in GitHub Desktop.
'''
------------------------------------------------------------------------------------------------
README CAREFULLY
OKAY !!!!!!
------------------------------------------------------------------------------------------------
Now we will see how to send email using smtplib
where as smtplib is a package/ module which is help to send the email
in this case we will be using gmail you can use any okay means outlook ,or any !
prerequisite :-
you must have to visit :- https://myaccount.google.com/lesssecureapps
after visiting this website you have to turn on the less secure app button ,
'''
import smtplib as s
'''
importing stmtplib module where s is instanse of smtplib.
'''
ob = s.SMTP("smtp.gmail.com",587)
'''
we creating ob as object You must have to mention the your services name in case;
we are using gmail thats why our service will be smtp.gmail.com , 587 is the post no of following services
you have to mention your port no according to service okay !
'''
madd = 'tejasdixit17@gmail.com'
#store email into in variable
pwd = 'TYPE_YOUR_OWN_PASSWORD_HEARE'
# strore password into variable even you can store into file also okay ! .
ob.starttls()
# startttls() is funcation which helps to start secure connecation !
ob.login(madd,pwd)
#login funaction take two arguments email and password ! .
print("checking ......! ")
#just statment
subject = 'hello check test mail ok '
#subject for email
body = 'hello hi how are you? '
#conatent for email
message = "subject :{}\n\n Body:{}".format(subject,body)
#format messsage
li = ['tejasdixit17@gmail.com','vbg3008@gmail.com','pandatd@protonmail.com','samubhamre@gmail.com','kunaljagate04@gmail.com']
#list os emails we have to send
ob.sendmail(madd,li,message)
#sendmail is use to send mail
print("email send succesfuly !!! ")
#where the statmet for confermetion which email send successfuly !
ob.quit()
# quite the connecation its mandetory
'''
------------------------------------------------------------------------------------------------
ANY QUERIES OR DOUBTS !! CONTACT
------------------------------------------------------------------------------------------------
NAME :- TEJAS DIXIT
GITHUB USERNAME :- PANDA__TD
INSTAGRAM USERNAME :- @_PANDATD
VISIT BLOG :- https://www.coddesclub.wordpress.com/
------------------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment