This Python script allows you to send personalized emails in bulk to a list of recipients from an Excel file. It supports Gmail accounts, HTML email templates, and Cc functionality for specific addresses.
- Sends personalized bulk emails to recipients listed in an Excel file.
- Allows HTML email templates for custom styling and personalization.
- Option to create a configuration file for storing Gmail credentials.
- Uses Gmail's SMTP server to send emails.
- Adds a Cc list to every email sent.
git clone https://github.com/paratpanu18/python-auto-email.git
cd python-auto-emailpip install -r requirements.txtIf the config.json file is not found, the script will prompt you to create one. It securely stores your Gmail email and password.
If the config.json file is not present when the code is executed, a new configuration file will be automatically generated.
Here is the format of config.json file:
{
"gmail_user": "john.doe@example.com",
"gmail_password": "https://youtu.be/elsh3J5lJ6g"
}Prepare an Excel file (contacts.xlsx by default) containing your recipients. The file should have at least two columns: Name and Email. Here's an example:
| Name | |
|---|---|
| John Doe | john.doe@example.com |
| Jane Smith | jane.smith@example.com |
| Alice Brown | alice.brown@example.com |
| Bob White | bob.white@example.com |
| Charlie Lee | charlie.lee@example.com |
Create an HTML file for your email body (e.g., email_template.html). You can use {name} as a placeholder for the recipient's name. Here's an example template:
<!DOCTYPE html>
<html>
<body>
<h1>Hello {name}!</h1>
<p>We are excited to announce our new service.</p>
</body>
</html>python main.pyThe script will prompt you to enter the following:
- Email subject
- HTML email template file (default: email_template.html)
- Excel contacts file (default: contacts.xlsx)
- SMTP server (default: smtp.gmail.com)
- SMTP port (default: 587)
As the script runs, it will provide real-time feedback, indicating whether the emails were successfully sent.
[1/100] Email successfully sent to John Doe (john.doe@example.com)
[2/100] Email successfully sent to Jane Smith (jane.smith@example.com)- Cc List: You can modify the cc list in the script to include email addresses that should receive a copy of every email.
- Email Template: Modify the HTML template to create a more personalized or branded email layout.
- SMTP Settings: The default SMTP server is Gmail. You can modify it if you're using a different email provider by changing the SMTP server and port.