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.
- use Devel mail logger
- configure postfix to write mail to disk
- use Reroute mail module
In this post, I will not go into setting up postfix or using redirect mail. Instead, I will explain how to write mail to disk. This method works without connection to the internet, which can be very convenient.
The Devel module comes with a mail system which writes mail to disk. To utilize this feature follow the steps below:
- Install and enable the Devel module
- Enable the Development mail system, by adding the following lines to your
settings.php
:// Enable the Devel Mail logger using code. $conf['mail_system'] = array( 'default-system' => 'DevelMailLog', );
- that's all, let Drupal send a mail and find in your configured
temporary://
directory.
customize the directory Development mail system will log to.
By default Devel Mail logger will write mail to temporary://devel-mails
. Add the following lines to your settings.php
to out put the mail to an other path:
// Custom mail log path.
$conf['devel_debug_mail_directory'] = '/path/to/folder';
source: devel.mail.inc