Is it possible to store the outbound mail settings in civicrm.settings.php? SMTP server IP address, port, user...

  • If you can provide a few more details on why you want to do this, I might be able to be of more help and expand on my answer below. Nov 10, 2017 at 9:54
  • The reason is that depending on where the site is deployed (live, staging, local machine) other outbound mail settings should be defined.
    – AlainB
    Nov 10, 2017 at 11:55
  • Another approach is to use the API to edit the settings as part of a clone to staging / local machine script. Nov 10, 2017 at 13:50

2 Answers 2


In civicrm.settings.php

global $civicrm_setting; $civicrm_setting['Mailing Preferences']['mailing_backend'] = [ 'outBound_option' => 0, 'smtpServer' => 'localhost', 'smtpPort' => 1025, 'smtpAuth' => false ];


No. Outbound mail settings are typically configured here: civicrm/admin/setting/smtp. They can't be overridden in civicrm.settings.php apart from to disable them completely by defining CIVICRM_MAIL_LOG, e.g.

define('CIVICRM_MAIL_LOG', '/var/log/civicrm_mail');


define('CIVICRM_MAIL_LOG', '/dev/null');

If you aren't interested in them.

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.