Debugging eMails in Symfony 2/3 and Drupal 7/8

Submitted by Peter Majmesku on Fri, 06/30/2017 - 22:33

The best tool for debugging eMails locally in my opinion is Mailcatcher. It catches all mails being sent via a specific port and shows them to you via an neat interface in your webbrowser. Firstly install Mailcatcher. It's programmed in Ruby and I could install it easily on Ubuntu and Mac. The instructions can be found at https://mailcatcher.me/.

Symfony 2/3

In the full stack edition it comes with symfony/swiftmailer-bundle. Make sure these settings are in your parameters.yml + parameters.yml.dist file.

mailer_transport: smtp
mailer_host: 127.0.0.1:1025
mailer_user: ~
mailer_password: ~

Afterwards you can send a test mail via the console:

bin/console swiftmailer:email:send

The mails will be shown to you like in the screenshot below.

The Mailcatcher Interface in Webbrowser

Drupal 7/8

Beside Drupal 8 install the "SMTP Authentication Support". You can find it's project webpage at https://www.drupal.org/project/smtp. Then visit the following page in your Drupal 8 instance: http://your-neat-webpage.dev/admin/config/system/smtp. Make sure the following settings are set in the config form (there's also a possibility to set them in the settings.php file).

SMTP server: 127.0.0.1
SMTP backup server: LEAVE BLANK
SMTP port: 1025
Use encrypted protocol: No

SMTP AUTHENTICATION: LEAVE USERNAME + PASSWORD BLANK

E-MAIL OPTIONS: ANY EMAIL AND FROM NAME

SEND TEST E-MAIL: ANY E-MAIL ADDRESS

Check "Enable debugging".

First part of settings form in Drupal 8
Second part of settings form in Drupal 8

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.