Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- from email.mime.text import MIMEText
- from email.mime.multipart import MIMEMultipart
- from email.mime.base import MIMEBase
- from email import encoders
- import os
- os.system("cls")
- # Setup port number and server
- smtp_port = 587
- smtp_server = "smtp.gmail.com"
- # Change this to your gmail id and set password
- email_from = "[email protected]"
- password = "setupPassword"
- email_to_list = [
- subject = " Invitation for Participation in Code Peak 2022 by NJACK IIT Patna and Coding Club of IIT Guwahati"
- def sendMail(email_list):
- for person in email_list:
- msg = MIMEMultipart()
- msg['From'] = email_from
- msg['To'] = person
- msg['Subject'] = subject
- # Adding cc
- cc = "[email protected]"
- msg['Cc'] = cc
- body = '''Greetings from the community of programmers of IIT Patna and IIT Guwahati!
- It gives us immense pleasure to announce that after one successful edition of Codepeak 2021, the NJACK IIT Patna and Coding Club of IIT Guwahati are organizing the 2nd edition of CODEPEAK website (Previously known as NWOC https://njackwinterofcode.github.io/).
- CODE PEAK is a month-long program that helps students understand the paradigm of Open Source contribution and gives them real-world software development experience. The event targets first-timers who wish to participate in Free and Open Source(FOSS) Contributions and experienced developers who want to show their skills by contributing to real-world projects.
- With this spirit, CODEPEAK is pleased to invite the students of your institute to be a part of the Competitions this year!
- We humbly request you share this message with your students (via the mailing lists, etc.) so that interested students do not miss out on this opportunity for growth and personal development.
- Please reply with a confirmation if you accept the above request!
- Students' registration for CODEPEAK 22 has started.
- One can check the complete timeline and details regarding Codepeak at https://www.codepeak.tech/
- Best Regards
- Vaibhav
- Organizing team
- Code Peak 2022
- '''
- # Adding mail body
- msg.attach(MIMEText(body, 'plain'))
- # File to be sent as attachment
- fileName = "Codepeak.png"
- # Opening file as binary
- file = open(fileName, "rb")
- # Encoding file as Base64
- attchment_package = MIMEBase("application", "octet-stream")
- attchment_package.set_payload((file).read())
- encoders.encode_base64(attchment_package)
- attchment_package.add_header("Content-Disposition", 'attachment; filename= '+ fileName)
- msg.attach(attchment_package)
- # Casting msg as string
- text = msg.as_string()
- print("Sending email...")
- TIE_SERVER = smtplib.SMTP(smtp_server, smtp_port)
- TIE_SERVER.starttls()
- TIE_SERVER.login(email_from, password)
- print("Connected to server :}")
- print()
- try:
- print("Sending email to", person)
- TIE_SERVER.sendmail(email_from, person, text)
- print("Email sent successfully to", person)
- except:
- print("Failed to send mail to", person)
- print()
- TIE_SERVER.quit()
- sendMail(email_to_list)
Add Comment
Please, Sign In to add comment