This Python script checks a specified email address for alerts sent by specific email senders and sends SMS notifications using an SMS Gateway. It utilizes the exchangelib
library for interacting with the email server and the requests
library for sending SMS messages.
- Python 3.x is required to run this script.
exchangelib
library (pip install exchangelib
)requests
library (pip install requests
)- Access to an email account with Exchange Web Services (EWS) enabled.
- An SMS Gateway API key or access.
-
Clone or download the repository to your local machine.
-
Create a file name
email_senders.txt
in the same directory as the script. List the email senders for which you want to receive alerts, each on a new line.Example
email_senders.txt
:sender1@example.com sender2@example.com
-
Open the
config.py
file and provide the necessary configurations:EMAIL_ADDRESS
: The email address you want to monitor for alerts.EMAIL_PASSWORD
: The password for the email address.SMS_GATEWAY_API_URL
: The URL of the SMS Gateway API.SMS_GATEWAY_API_KEY
: Your API key for the SMS Gateway.
Run the script using the following command:
python email_alert_sms_notifier.py
The script will connect to the specified email address, check for emails from the configured senders, and if an alert is found, it will extract the email contents and send an SMS notification using the SMS Gateway.
To automate the script on a Linux system using cron jobs, follow these steps:
- Open the terminal
- Edit the user's crontab using the command:
crontab -e
- Add the following line to run the script every hour:
0 * * * * /usr/bin/python /path/to/email_alert_sms_notifier.py
- Save and exit the crontab editor.
To automate the script on a Windows system using Task Scheduler, follow these steps:
-
Open Task Scheduler from the Start menu.
-
Click on "Create Basic Task" and follow the wizard to create a new task.
-
Specify the name and description for the task.
-
Choose the "Daily" or "Hourly" trigger, depending on your preference.
-
Select "Start a program" as the action and browse to the location of your Python executable (
python.exe
) and the script (email_alert_sms_notifier.py
). -
Complete the wizard and save the task.
This project is licensed under the MIT License