redirect mail in Drupal to disk

When developing applications in Drupal you need to send mails from time to time. You can configure postfix or another mail server to send mail. Sometimes you can do without, or you do not want to let emails get out of your development machine at all. Imagine yourself working on a site with lots of users and want to test a part of the code which sends mail to users. You do not want to send mail to the users from your development environment. There are several ways to keep your installation from sending mail to users.