Sending automatic mails

Sending automatic mails

How can i send automatic mail alert when a case is pending for more than 2 days, and also notify the customer when a case is closed.