SSL encryption (SMTP_SSL) provided by the smtplib library
.Python
Importing Required Libraries: The script starts by importing necessary modules from the smtplib
and email.mime packages
. These are used for sending emails.
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import os
import time
print("Welcome to InboxMaster")
emailList = ['########', '########', '########']
MIMEMultipart
and MIMEText objects. Finally, it sends the email via an SMTP server using SSL encryption.def sendMail(fromEmail, toEmail, subject, message):
sendMail
that takes four parameters: fromEmail (sender's email address)
, toEmail (recipient's email address)
, subject (email subject)
, and message (email body)
. msg = MIMEMultipart()
msg.set_unixfrom("BhavdeepSinghNijhawan")
msg['From'] = fromEmail
msg['To'] = toEmail
msg['Subject'] = subject
msg.attach(MIMEText(message))
MIMEMultipart
message object and set its attributes such as sender, recipient, subject, and message body. mailserver = smtplib.SMTP_SSL('smtpout.secureserver.net', 465)
mailserver.ehlo()
mailserver.login(os.environ['email'], os.environ['password'])
mailserver.sendmail(fromEmail, toEmail, msg.as_string())
mailserver.quit()
sendMail
function to send the email.for email in emailList:
fromEmail = "########"
subject = "Welcome to InboxMaster"
message = "This is a Test for InboxMaster"
sendMail(fromEmail, email, subject, message)
print(f"Mail sent to - {email}")
time.sleep(2)
print("All E-Mails are Sent Successfully")