TECH PIXEL

Welcome to Python Practice Projects at techtpixel.xyz — your one-stop hub to master Python through real-world, beginner to advanced projects. Learn by building web apps, scripts, automation tools, APIs, and more. Whether you're into data science, Django, Flask, or interview prep, our hands-on tutorials help you level up your skills and build a strong portfolio. Start coding smarter with practical Python challenges today!

How to 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()

Post a Comment

0 Comments