Answers.Body: <p>I was incorrect, the password is not being deleted. It just requires a certain flag to be passed to load in the existing password, which is saved in the database.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-09T17:13:42.567Z
Answers.LastActivityDate: 2022-09-09T17:13:42.567Z
Answers.UserDisplayName: selfagency
Answers.Body: <p>I had the same issue with an installation of a client.</p>
  <p>It appeared that the drupal settings.php file contained this:</p>
  <p><code>ini_set('arg_separator.output', '&amp;amp;');</code></p>
  <p>This interferes with the method that encrypts the SMTP parameters and that stores them in the database.</p>
  <p>The method encrypt() in Civi/Crypto/CryptoToken.php uses the PHP function http_build_query without specifying the $arg_separator. The default is an ampersand, but in the case of my client, the value of arg_separator.output was taken. The decrypt function however, expects an ampersand.</p>
  <p>That's why the password can be encrypted, but not properly decrypted.</p>
  <p>If you encounter this edge case, search for <code>arg_separator.output</code> in your php.ini file and in the settings file of the CMS and CiviCRM, and put this statement in comments or remove it all together.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-25T16:36:46.480Z
Answers.LastActivityDate: 2024-04-25T16:36:46.480Z
Answers.UserDisplayName: AlainB
Body: <p>I am configuring the latest version of CiviCRM (Drupal) to use Mailgun as an external SMTP service. When I go to <code>Administer &gt; System Settings &gt; Outbound Email</code>, enter the SMTP credentials, and click <code>Save &amp; Send Test Email</code>, everything works great, I receive the test email, and the masked password continues to appear in the password field. If I then go to send a mailing, my emails all bounce with the error:</p>
  <blockquote>
  <p>authentication failure [SMTP: Invalid response code received from SMTP server while sending email. This is often caused by a misconfiguration in Outbound Email settings. Please verify the settings at Administer CiviCRM &gt;&gt; Global Settings &gt;&gt; Outbound Ema</p>
  </blockquote>
  <p>When I return to the <code>Outbound Email</code> page, the masked password is now gone, and I'm unable to send another test without reentering the password. If I reenter the password and click <code>Save</code> instead of <code>Save &amp; Send Test Email</code> the same thing happens. When I return to the <code>Outbound Email</code> page, the saved password is gone.</p>
  <p>I didn't set up this CiviCRM installation, I'm just helping someone out with theirs. Is there a setting I'm missing that would account for this? Is it possible an overriding SMTP password is passed in as an environment variable somewhere or something?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-09T02:28:24.760Z
Comments.Text: Check in sites/default/civicrm.settings.php. Somebody may have set an override for smtp.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-09T02:32:14.057Z
Comments.Text: Also if it's a recent-ish version of civi check if civicrm.settings.php has CIVICRM_CRED_KEYS and CIVICRM_SIGN_KEYS defined. If not you can use this tool to generate: https://civisettings.symbiotic.coop/
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-09T15:43:38.400Z
Comments.Text: @Demerit There are cred and sign keys but nothing related to SMTP.
Comments.UserDisplayName: selfagency
Tags: <drupal><email><smtp>
Title: SMTP password deletes itself from Outbound Email settings
ThreadText: # SMTP password deletes itself from Outbound Email settings
  
  (Asked by: username_0 on 2022-09-09)
  
  I am configuring the latest version of CiviCRM (Drupal) to use Mailgun as an external SMTP service. When I go to `Administer > System Settings > Outbound Email`, enter the SMTP credentials, and click `Save & Send Test Email`, everything works great, I receive the test email, and the masked password continues to appear in the password field. If I then go to send a mailing, my emails all bounce with the error:
  
  > authentication failure [SMTP: Invalid response code received from SMTP server while sending email. This is often caused by a misconfiguration in Outbound Email settings. Please verify the settings at Administer CiviCRM >> Global Settings >> Outbound Ema
  
  When I return to the `Outbound Email` page, the masked password is now gone, and I'm unable to send another test without reentering the password. If I reenter the password and click `Save` instead of `Save & Send Test Email` the same thing happens. When I return to the `Outbound Email` page, the saved password is gone.
  
  I didn't set up this CiviCRM installation, I'm just helping someone out with theirs. Is there a setting I'm missing that would account for this? Is it possible an overriding SMTP password is passed in as an environment variable somewhere or something?
  
  **Tags:** drupal, email, smtp
  
  > **Comments:**
  > **username_1**: Check in sites/default/civicrm.settings.php. Somebody may have set an override for smtp.  
  > **username_1**: Also if it's a recent-ish version of civi check if civicrm.settings.php has CIVICRM_CRED_KEYS and CIVICRM_SIGN_KEYS defined. If not you can use this tool to generate: https://civisettings.symbiotic.coop/  
  > **username_0**: @username_1 There are cred and sign keys but nothing related to SMTP.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2022-09-09. Score: 2
  
  I was incorrect, the password is not being deleted. It just requires a certain flag to be passed to load in the existing password, which is saved in the database.
  
  
  ---
  
  ### Answer by username_2 on 2024-04-25. Score: 1
  
  I had the same issue with an installation of a client.
  
  It appeared that the drupal settings.php file contained this:
  
  `ini_set('arg_separator.output', '&');`
  
  This interferes with the method that encrypts the SMTP parameters and that stores them in the database.
  
  The method encrypt() in Civi/Crypto/CryptoToken.php uses the PHP function http\_build\_query without specifying the $arg\_separator. The default is an ampersand, but in the case of my client, the value of arg\_separator.output was taken. The decrypt function however, expects an ampersand.
  
  That's why the password can be encrypted, but not properly decrypted.
  
  If you encounter this edge case, search for `arg_separator.output` in your php.ini file and in the settings file of the CMS and CiviCRM, and put this statement in comments or remove it all together.
  
  
  ---
  
  