Answers.Body: <p>Got it. To see current value, run:</p>
  
  <pre><code>select * from civicrm_setting where name='mailing_backend';
  </code></pre>
  
  <p>Because it's PHP serialise format, there is no easy change to change one value only! Sigh. I would recommend setting your app to dummy variables, then running the above to get the current value, then sticking that in a update statement to give you something like:</p>
  
  <pre><code>update civicrm_setting set value='a:10:{s:15:"outBound_option";s:1:"0";s:5:"qfKey";s:37:"xxxxxxxxxxxxx";s:8:"entryURL";s:131:"https://xxxxxxxxxxxx";s:13:"sendmail_path";s:0:"";s:13:"sendmail_args";s:0:"";s:10:"smtpServer";s:9:"localhost";s:8:"smtpPort";s:2:"25";s:8:"smtpAuth";s:1:"0";s:12:"smtpUsername";s:0:"";s:12:"smtpPassword";s:0:"";}' where name='mailing_backend';
  </code></pre>
  
  <p>Hopefully, in future that update statement will set your SMTP settings back to dummy variables!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-19T12:10:34.180Z
Answers.Text: Could be make with a regex to avoid change the another params (in mariadb works, not sure mysql)
  
  ```sql
  UPDATE civicrm_setting SET value = REGEXP_REPLACE(value,'outBound_option\";s:1:\"[0-9]','outBound_option\";s:1:\"5') WHERE name = "mailing_backend";
  ```
Answers.UserDisplayName: rubofvil
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-15T15:09:04.497Z
Answers.LastActivityDate: 2016-06-15T15:09:04.497Z
Answers.UserDisplayName: James
Answers.Body: <p>In civicrm.settings.php, add the following:</p>
  
  <pre><code>define('CIVICRM_MAIL_LOG', 1);
  </code></pre>
  
  <p>This will route all email to files/civicrm/ConfigAndLog/mail (Drupal) or media/civicrm/ConfigAndLog (Joomla).</p>
  
  <p>You can also specify:</p>
  
  <pre><code>define('CIVICRM_MAIL_LOG', "your_file_path");
  </code></pre>
  
  <p>to set a specific output file.</p>
  
  <p>See <a href="https://wiki.civicrm.org/confluence/display/CRMDOC/Debugging+for+developers" rel="nofollow">https://wiki.civicrm.org/confluence/display/CRMDOC/Debugging+for+developers</a>.</p>
  
  <p>Another option is to perform the following queries to kill any scheduled or queued mail:</p>
  
  <pre><code>UPDATE `civicrm_mailing_job` SET `status`= 'Complete' WHERE `status` IN ('Scheduled', 'Running', 'Paused')
  DELETE FROM `civicrm_mailing_spool` WHERE 1
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-15T14:43:38.500Z
Answers.Text: Thanks for the mail log! Will test soon. Good call on the `civicrm_mailing_spool` trick, tho that only stops existing emails, and I'd like to change the settings to also stop any new emails that might be made in testing.
Answers.UserDisplayName: James
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-15T16:18:06.523Z
Answers.Text: Yes civicrm_mail_log is an excellent solution!
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-15T14:26:24.473Z
Answers.LastActivityDate: 2016-06-15T14:26:24.473Z
Answers.UserDisplayName: BobS
Answers.Body: <p>I created a small <strong>drush</strong> plugin that just does this. It also disables the standard drupal email.
  <code>
   function drush_modulename_commandname(){
      drush_print('Disabling outgoing email - drupal &amp; civi');
      civicrm_initialize();
      $result = civicrm_api3('Setting', 'create', array(
          'mailing_backend' => array('outBound_option'=> CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB),
      ));
      if($result["is_error"]){
         drush_log('CiCRM Error'.$result['error_message'],'ok');
      }
      variable_set('mail_system',array (
       'default-system' => 'TestingMailSystem',
       'mimemail' => 'TestingMailSystem',
      ));
      drush_print('Done');
    }
  </code> 
  Information how to create drush commands can be found on <a href="http://docs.drush.org/en/master/commands/" rel="nofollow">http://docs.drush.org/en/master/commands/</a> </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-28T08:36:20.913Z
Answers.LastActivityDate: 2016-10-28T08:36:20.913Z
Answers.UserDisplayName: Kainuk - CiviCooP
Answers.Body: <p>You can use <a href="https://www.drupal.org/project/civicrm_reroute_email" rel="nofollow">https://www.drupal.org/project/civicrm_reroute_email</a> module and enable it on test env, which will reroute all CiviCRM emails to the specified email address. This will work with Drupal.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-15T09:12:05.673Z
Answers.LastActivityDate: 2016-06-15T09:27:40.987Z
Answers.LastEditDate: 2016-06-15T09:27:40.987Z
Answers.UserDisplayName: Sushant
Body: <p>How can I activate the "Disable Outbound email" option or change the SMTP server address with only an SQL Query?</p>
  
  <p>(My use case is when I copy live data to a test environment, I obviously want to make sure no real emails are sent from the test environment!)</p>
  
  <p>Thanks,</p>
  
Tags: <email>
Title: Disable Outbound email or change SMTP server with an SQL Query?
ThreadText: # Disable Outbound email or change SMTP server with an SQL Query?
  
  (Asked by: username_0 on 2016-06-15)
  
  How can I activate the "Disable Outbound email" option or change the SMTP server address with only an SQL Query?
  
  (My use case is when I copy live data to a test environment, I obviously want to make sure no real emails are sent from the test environment!)
  
  Thanks,
  
  **Tags:** email
  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_0 on 2016-06-15. Score: 1 | Accepted answer
  
  Got it. To see current value, run:
  
  ```
  select * from civicrm_setting where name='mailing_backend';
  
  ```
  
  Because it's PHP serialise format, there is no easy change to change one value only! Sigh. I would recommend setting your app to dummy variables, then running the above to get the current value, then sticking that in a update statement to give you something like:
  
  ```
  update civicrm_setting set value='a:10:{s:15:"outBound_option";s:1:"0";s:5:"qfKey";s:37:"xxxxxxxxxxxxx";s:8:"entryURL";s:131:"https://xxxxxxxxxxxx";s:13:"sendmail_path";s:0:"";s:13:"sendmail_args";s:0:"";s:10:"smtpServer";s:9:"localhost";s:8:"smtpPort";s:2:"25";s:8:"smtpAuth";s:1:"0";s:12:"smtpUsername";s:0:"";s:12:"smtpPassword";s:0:"";}' where name='mailing_backend';
  
  ```
  
  Hopefully, in future that update statement will set your SMTP settings back to dummy variables!
  
  > **Comments:**
  > **username_1**: Could be make with a regex to avoid change the another params (in mariadb works, not sure mysql)  ```sql UPDATE civicrm_setting SET value = REGEXP_REPLACE(value,'outBound_option\";s:1:\"[0-9]','outBound_option\";s:1:\"5') WHERE name = "mailing_backend"; ```  
  
  ---
  
  ### Answer by username_2 on 2016-06-15. Score: 4
  
  In civicrm.settings.php, add the following:
  
  ```
  define('CIVICRM_MAIL_LOG', 1);
  
  ```
  
  This will route all email to files/civicrm/ConfigAndLog/mail (Drupal) or media/civicrm/ConfigAndLog (Joomla).
  
  You can also specify:
  
  ```
  define('CIVICRM_MAIL_LOG', "your_file_path");
  
  ```
  
  to set a specific output file.
  
  See <https://wiki.civicrm.org/confluence/display/CRMDOC/Debugging+for+developers>.
  
  Another option is to perform the following queries to kill any scheduled or queued mail:
  
  ```
  UPDATE `civicrm_mailing_job` SET `status`= 'Complete' WHERE `status` IN ('Scheduled', 'Running', 'Paused')
  DELETE FROM `civicrm_mailing_spool` WHERE 1
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks for the mail log! Will test soon. Good call on the `civicrm_mailing_spool` trick, tho that only stops existing emails, and I'd like to change the settings to also stop any new emails that might be made in testing.  
  > **username_3**: Yes civicrm_mail_log is an excellent solution!  
  
  ---
  
  ### Answer by username_4 on 2016-10-28. Score: 1
  
  I created a small **drush** plugin that just does this. It also disables the standard drupal email.
  `function drush_modulename_commandname(){
  drush_print('Disabling outgoing email - drupal & civi');
  civicrm_initialize();
  $result = civicrm_api3('Setting', 'create', array(
  'mailing_backend' => array('outBound_option'=> CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB),
  ));
  if($result["is_error"]){
  drush_log('CiCRM Error'.$result['error_message'],'ok');
  }
  variable_set('mail_system',array (
  'default-system' => 'TestingMailSystem',
  'mimemail' => 'TestingMailSystem',
  ));
  drush_print('Done');
  }`
  Information how to create drush commands can be found on <http://docs.drush.org/en/master/commands/>
  
  
  ---
  
  ### Answer by username_5 on 2016-06-15. Score: 1
  
  You can use <https://www.drupal.org/project/civicrm_reroute_email> module and enable it on test env, which will reroute all CiviCRM emails to the specified email address. This will work with Drupal.
  
  
  ---
  
  