A Python3 script to fetch iCalendar/ical/ics-feeds from the web and send an email with upcoming events.
In order to use this script you need
- a SMTP account/server
- one or more URLs to ICS/iCalendar files
- Python 3, pip and virtualenv installed.
Download this repository, create a new virtualenv and configure the script.
git clone git@github.com:HerHde/ical2mail.git
cd ical2mail
virtualenv --python=/usr/bin/python3 venv
source venv/bin/activate
pip install -r requirements.txt
Now copy/rename the config.py.sample
to config.py
, open it in your preferred editor and make adjustments, at least you need to configure MAIL_FROM
, MAIL_TO
, ICAL_URLS
and the SMTP_*
variables.
You need to enter the virtualenv
every time you are in a new shell session. Inside the repository's directory run
source venv/bin/activate
python ical2mail.py
If no text appears, everything went well!
To run this script periodically, you need to set up a cronjob. To send a, lets say weekly mail, listing the appointment for the next seven days, set DAYS_NEXT = 7
in your config.py
and install your cronjob:
pwd # returns the path of your current directory, assuming that you are in the ical2mail dir
crontab -e
Insert the following at the end of the file:
0 0 * * 1 <output of pwd>/run_cron.sh
Where you replace <output of pwd>
. This runs the script every monday at 00:00
To get a different formatted output, you can use Jinja2-templates. Modify the default template or create a new one in the templates/
folder and update the config.
This script is inspired by Cord Beermann's Calendar2Mail script, which is written in Pearl and served my purposes well for a long time. Thank you Cord!
I heavily used Severin "tiefpunkt" Schols's ical2email as a base, a Python 2 script, which does slightly the same as this script, but in a different manner. Thank you tiefpunkt! Without your script I would have procrastinated the implementation of mine a long time.
This script is written and maintained by Henrik "HerHde" Hüttemann.
This work is licensed under the GNU GPLv3.