Unit Testing Email and Email templates

What’s the best way to write unit tests and integration tests for testing emails? I want to send email and confirm the dynamic contents of the email in the test cases. Also want do integration testing to confirm emails are triggered on particular events in the application.