Send Multiple Emails using Python
Sending mails can be a very tough task if you want to send them to multiple devices and users. Python comes with various inbuilt modules. For sending mails, python uses Simple Mail Transfer Protocol (SMTP). It will use ports 465 to 587.
You need to enter your login credentials and full message details in the sublime, and you can send emails in bulk. You can add the subject, body of the mail, list of the total recipients and send it to the whole list. Python email codes are used to add Python email attachments as well.
code:
import smtplib as s
ob = s.SMTP('smtp.gmail.com',587)
ob.ehlo()
ob.starttls()
ob.login('example21@gmail.com','use your password here')
subject = "test python"
body = " I love python"
message = "subject:{}\n\n{}".format(subject, body)
listadd = ["techhpixel@gmail.com"]
ob.sendmail('aroojamina82@gmail.com', listadd, message)
print("send mail")
ob.quit()
0 Comments