This Python script automates the process of forwarding unread emails from a RainLoop webmail interface to another email address using Selenium WebDriver.
- Automated Login: Logs into RainLoop using provided credentials.
- Unread Email Detection: Finds emails marked as unread (using the
.unseenCSS class). - Forwarding: Initiates the forwarding process for each unread email by clicking the forward button within the email list item.
- Form Population: Fills the "To" field in the forwarding form with a specified email address.
- Sending: Submits the forwarding form to send the email.
- Headless Operation: Runs in headless mode by default, suitable for background execution.
- Periodic Execution: Designed to be run periodically (e.g., via
cron) to check for new emails.
- Python 3.x
seleniumwebdriver-manager- Chrome or Chromium browser installed (for
chromedrivermanaged bywebdriver-manager)
- Clone the repository or download the script.
- Install Python dependencies:
(Ensure
pip install -r requirements.txt
requirements.txtcontainsseleniumandwebdriver-manageras specified earlier).
-
Edit the script (
mail.py):- Set the
login_urlto your RainLoop instance (e.g.,https://your-webmail-domain.com). - Set the
usernameandpasswordfor your RainLoop account. - Set the
yandex_email(or any other email address) to which you want to forward the emails. - Adjust the
chrome_optionsif needed (currently configured for headless operation). - Adjust the
waittimeout values if necessary for your network/system speed.
- Set the
-
(Optional) Create a
cronjob:- To run the script every 10 minutes, add the following line to your crontab (
crontab -e):Replace*/10 * * * * /path/to/your/python /path/to/this/script/mail.py >> /path/to/logfile.log 2>&1
/path/to/your/python,/path/to/this/script/mail.py, and/path/to/logfile.logwith the actual paths on your system.
- To run the script every 10 minutes, add the following line to your crontab (
Run the script directly using Python:
python mail.py