NWS letter
NWS letter
Project Description
The Python Automated Email Newsletter Sending Script offers an effective and automated way to send newsletters to a list of subscribers.
.
Table of Contents
About
The Python script automates the sending of newsletters via email to a list of subscribers. It uses the Gmail API to create and send customized emails from a defined sender to recipients in a CSV file. With a graphical interface, users enter the subject and content, which are sent to all subscribers. The script handles errors and simplifies communication with subscribers, making information sharing efficient and personalized.
Installation
-
Install Python on your computer.
-
Verify the installation in the Command Prompt by typing:
python3
-
Clone the repository using the following command:
# Clone the repo $ git clone https://github.com/ravimughal/newsletter.git
-
Access the Google Developer Console: Go to https://console.developers.google.com/ and log in to your Google account.
-
Create a New Project: In the Developer Console, click the “Select a project” button in the top left corner, then click “New Project.” Give the project a name and select the appropriate options. Click “Create.”
-
Activate the Gmail API: In the project dashboard, click “Enable APIs and Services.” Search for “Gmail” and click “Gmail API.” Then, click the “Enable” button.
-
Create Credentials: In the left-hand menu, click “Credentials.” Next, click “Create credentials” and choose “OAuth Client ID.” Select “Desktop App” as the application type.
-
Configure the Credentials: Fill in the application details such as the name and icon. You can add “http://localhost” to the authorized redirect URLs for testing purposes. Click “Create” to create the credentials.
-
Download the Credentials: In the list of credentials, you’ll see the new credential you created. Click the download icon next to it to download the JSON file containing authentication information.
-
Use the Credentials: In your code, use the JSON credentials file to authenticate your application and access the Gmail API. Place the ‘path_to_credentials.json’ file in the NEWSLETTER folder.
-
In your code, replace ‘testedasilvafilho@gmail.com’ with your email address in the ‘main.py’ file:
sender_email = 'testedasilvafilho@gmail.com'
Also, replace ‘testedasilvafilho@gmail.com’ with your email in the ‘email_utils.py’ file:
if sender == 'testedasilvafilho@gmail.com':
How to Use
-
Navigate to the ‘newsletter’ directory in your Command Prompt and run ‘main.py’ using the following command:
cd newsletter python main.py
-
Enter the email subject and message content that will be sent to the emails listed in ‘lista_assinantes.csv.’
-
Access the email account you registered during the installation.
Prerequisites
Technologies