Now that I am supporting Drupal 10, I needed to set up Mailhog to allow local capturing of emails when I'm testing in my local Docker environment.

I used to use the SMTP and Mail System modules and used overrides in my settings.php file to set the port and host etc to mailhog i.e. host 'mail' and port '1025' as per my local Docker set up.

I have switched to using Symfony Mailer now for sending emails in production. What is the syntax for the override in settings.php? I have searched but there is not a clear answer - there was a lot of discussion around Sendmail and Swiftmailer, but I want a simple answer to overriding my SMTP transport setting to use another hostname and port.

1 Answer 1


These are the correct overrides for Symfony Mailer for my setup. Just replace the host, port username and password with your own. The 'Perform TLS peer verification' tickbox is dealt with on the last line - 'query_peer'. 'True' sets this checkbox to yes.


If you do a drush config:get on your production setup, you will get something like this:

www-bridge-user@a8e972098567:/var/www/html$ vendor/bin/drush config:get symfony_mailer.mailer_transport.smtp
uuid: a0c04a65-de79-4c81-9466-ad87c6ea1298
langcode: en
status: true
dependencies: {  }
id: smtp
label: SMTP
plugin: smtp
  user: ''
  pass: ''
  host: your-smtp-host-name.com
  port: 587
    verify_peer: true
    local_domain: ''
    restart_threshold: null
    restart_threshold_sleep: null
    ping_threshold: null

I used the same YML structure in creating a block for settings. Each indent is a new set of brackets after the top level key of symfony_mailer.mailer_transport.smtp

NOTE WELL: If you look at the UI or go a config:get, you will NOT see the overrides you have put in settings.php, so ensure you test this thoroughly.

Hope this helps others. Might be useful if you wish to keep your SMTP settings out of the UI as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.