Answers.Body: <p>Use something like:</p>
  <p><code>$civicrm_setting['Mailing Preferences']['mailing_backend']['smtpPort'] = '587';</code></p>
  <p>I think the group name <code>'Mailing Preferences'</code> is obsolete and could be <code>'domain'</code>, but the above works.</p>
  <p>You could also use the <code>define('CIVICRM_MAIL_LOG')</code> which you'll find lower down in civicrm.settings.php to dump all mail raw to a file without sending it.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-23T17:25:05.240Z
Answers.Text: Thanks so much for that - works perfectly.  Tested with ['domain'] and this works so I have used this in preference to ['Mailing Preferences'].  I need to see the results of the various HTML templated emails that go out so this is ideal.
  
  For those using MailHog with Docker my civicrm.settings.php file now has:
  
  $civicrm_setting['domain']['mailing_backend']['smtpPort'] = '1025'; //MailHog smtp port
  $civicrm_setting['domain']['mailing_backend']['smtpServer'] = 'mail'; //Docker container
  $civicrm_setting['domain']['mailing_backend']['smtpAuth'] = 0; //No auth required
Answers.UserDisplayName: ChumKui
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-23T14:54:46.863Z
Answers.LastActivityDate: 2022-02-23T14:54:46.863Z
Answers.UserDisplayName: Demerit
Body: <p>For local development, so that I can test outgoing email safely, I use the Drupal settings.php file to store my MailHog email server settings e.g.</p>
  <pre><code>$conf['smtp_host'] = 'mail'; //Docker container
  $conf['smtp_port'] = '1025'; //MailHog port 
  </code></pre>
  <p>This way I can refresh the local database and it will immediately work in my local environment.</p>
  <p>I cannot see an obvious way of doing this for CiviCRM?  Looking at the API explorer, I have experimented with a few things like:</p>
  <pre><code>$civicrm_setting[mailing_backend]['smtpServer']
  </code></pre>
  <p>But does this not seem to work.  Can this be done? It would be nice to not have to change my SMTP setting each time.</p>
  
Tags: <civicrm.settings.php><smtp>
Title: Can I store local dev SMTP settings in civicrm.settings.php?
ThreadText: # Can I store local dev SMTP settings in civicrm.settings.php?
  
  (Asked by: username_0 on 2022-02-23)
  
  For local development, so that I can test outgoing email safely, I use the Drupal settings.php file to store my MailHog email server settings e.g.
  $conf['smtp_host'] = 'mail'; //Docker container
  $conf['smtp_port'] = '1025'; //MailHog port 
  
  This way I can refresh the local database and it will immediately work in my local environment.
  I cannot see an obvious way of doing this for CiviCRM?  Looking at the API explorer, I have experimented with a few things like:
  $civicrm_setting[mailing_backend]['smtpServer']
  
  But does this not seem to work.  Can this be done? It would be nice to not have to change my SMTP setting each time.
  
  **Tags:** civicrm.settings.php, smtp
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-02-23. Score: 4 | Accepted answer
  
  Use something like:
  
  `$civicrm_setting['Mailing Preferences']['mailing_backend']['smtpPort'] = '587';`
  
  I think the group name `'Mailing Preferences'` is obsolete and could be `'domain'`, but the above works.
  
  You could also use the `define('CIVICRM_MAIL_LOG')` which you'll find lower down in civicrm.settings.php to dump all mail raw to a file without sending it.
  
  > **Comments:**
  > **username_0**: Thanks so much for that - works perfectly.  Tested with ['domain'] and this works so I have used this in preference to ['Mailing Preferences'].  I need to see the results of the various HTML templated emails that go out so this is ideal.  For those using MailHog with Docker my civicrm.settings.php file now has:  $civicrm_setting['domain']['mailing_backend']['smtpPort'] = '1025'; //MailHog smtp port $civicrm_setting['domain']['mailing_backend']['smtpServer'] = 'mail'; //Docker container $civicrm_setting['domain']['mailing_backend']['smtpAuth'] = 0; //No auth required  
  
  ---
  
  