Script to Monitor MySQL Replication
The nagios monitoring scripts for mysql should be a good start.

If you want to monitor your database with this kind of email alerts, you should really try to setup nagios or some similar software as this is exactly the purpose of a monitoring software.