top of page

Make $1000 / Day With Python Email Automation In 2024

Updated: May 7

Email automation in python streamlines communication by automating repetitive tasks such as welcome emails, abandoned cart reminders, and personalized follow-ups. It enhances efficiency, engagement, and customer relationships. 📧✨


  • Personalization: Email automation allows you to personalize your customers’ experiences. By leveraging data such as behavior, preferences, and previous sales, you can send targeted and relevant messages to each recipient.

  • List Segmentation: Effective email automation software includes features for segmenting your email lists. You can group recipients based on demographics, behavior, engagement levels, or other criteria.

  • Workflow Automation: Email automation workflows are powerful tools. You can set up specific events (e.g., sign-ups, purchases, abandoned carts) to trigger automated email sequences.

  • Behavior-Based Triggers: With email automation, you can send messages based on user actions. For instance, you can automatically follow up with customers who viewed a product but didn’t make a purchase.

  • Analytics and Reporting: Good email automation software provides robust analytics. You can track open rates, click-through rates, conversion rates, and other metrics.


Before running the script, make sure you have Python installed on your system. Also, ensure you have following library:

pip install secure-smtplib
pip install os-sys
pip install mime
pip install schedule
pip install TIME-python
Project code:

List of smtp server with there ports:


  • SMTP Server (Outgoing Messages):

  • Non-Encrypted: Port 25 (or 587)

  • Secure (TLS/StartTLS): Port 587

  • Secure (SSL): Port 465

  • POP3 Server (Incoming Messages):

  • Non-Encrypted: Port 110

  • Secure (SSL): Port 995

Yahoo Mail


  • SMTP Server (Outgoing Messages):

  • StartTLS: Port 587

  • IMAP Server (Incoming Messages):

  • Secure (SSL): Port 995


BT Connect


  • SMTP Server (Outgoing Messages):

  • Secure (SSL): Port 465

  • POP3 Server (Incoming Messages):

  • Secure (SSL): Port 995

# Email-Automation system

import smtplib
import os
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
import schedule
import time

def setup_smtp_connection():
    smtp_server = "" # change in case of yahoo , outlook 
    smtp_port = 587 # change according to above
    sender_email = "" # add your email
    sender_password = "kjxz axvf aedv ceov"  # add your own password refer above video

    smtp = smtplib.SMTP(smtp_server, smtp_port)
    smtp.login(sender_email, sender_password)
    return smtp

def create_email(subject, text, recipients, img_path=None, attachments=None):
    msg = MIMEMultipart()
    msg['Subject'] = subject

    if img_path:
        img_data = open(img_path, 'rb').read()
        msg.attach(MIMEImage(img_data, name=os.path.basename(img_path)))

    if attachments:
        for attachment in attachments:
            with open(attachment, 'rb') as f:
                file = MIMEApplication(, name=os.path.basename(attachment))
                file['Content-Disposition'] = f'attachment; filename="{os.path.basename(attachment)}"'

    return msg

def send_emails(smtp, msg, recipients):
        smtp.sendmail(from_addr="", to_addrs=recipients, msg=msg.as_string())
        print("Email sent successfully!")
    except Exception as e:
        print(f"Error sending email: {e}")

def send_scheduled_emails():
    recipients = [""]
    subject = "Automated Job Application"
    email_text = "Hello\n i am mark, i am a python developer and i have a doubt can you solve it ??"
    image_path = "files/Add a heading.png"
    attachments_list = ["files/PyCharm_ReferenceCard.pdf","files/Add a heading.png"]

    smtp_connection = setup_smtp_connection()
    email_message = create_email(subject, email_text, recipients, img_path=image_path, attachments=attachments_list)
    send_emails(smtp_connection, email_message, recipients)


while True:

Usage of email automation in python:

  1. Welcome Series: When a new subscriber joins your email list, an automated welcome series can introduce them to your brand, share valuable content, and build a strong initial connection. It’s like rolling out the red carpet for your new audience members.

  2. Abandoned Cart Recovery: E-commerce businesses can set up automated emails to remind customers about their abandoned shopping carts. These gentle nudges often lead to recovered sales. 🛒

  3. Drip Campaigns: Drip campaigns involve sending a series of pre-scheduled emails over time. For instance, you can create a drip campaign for nurturing leads, educating prospects, or promoting a product launch. Each email builds on the previous one, gradually guiding recipients toward a desired action.

  4. Event Reminders and Follow-ups: Whether it’s a webinar, conference, or product launch, automated event reminders ensure that participants don’t miss important dates. Post-event follow-up emails can gather feedback, share resources, or offer exclusive deals.

  5. Segmented Promotions: Email automation allows you to segment your audience based on various criteria (e.g., behavior, demographics, purchase history). You can then send targeted promotions, discounts, or personalized recommendations. Segmentation ensures that the right message reaches the right people at the right time.


bottom of page