shell script to access MySQL DB and send email
Posted on 2004-10-12
First of all I am not sure if this question belongs to this category or if it doesnt, anyways, do point me out if wrong.
I have bought web hosting at a linux based server. I have created my personal events calendar in php (events.php). The events.php uses a MySQL database on the backend which stores all data for events.
Now what I want to be able to do is that whenever any of my events are coming up, I should be sent an email as a reminder about that event.
I figured that my hosting allows me to run unix commands at a particular time using CRON (The web hosting provides a web-based interface to CRON (CPanelX)).
Now .... the question!
1) How do i write a "unix command" that check out the upcoming events from the database and send an email with data from the MySQL database. Obviously its going to be a shell script. My initial research tells me that
I would need a code to access MySQL DB from shell account &&
I would need a code to send email from the shell account
Is that all I would be needing? If yes then how?
Preferably a code will be appreciated, links will work too.
I can raise the points, if requested.