Answers.Body: <p>Turns out I needed to enable masquerading on my server which &quot;allows users and apps to send emails with an arbitrary username in the FROM address.&quot;</p>
  <p>I am now able to send through CiviMail.</p>
  <p>I thought of this as the tail end of the error message was:</p>
  <blockquote>
  <p>(code: 550, response: Authenticated user user@example.com cannot send mail as b.17.14.5c9e67488c7c2078@example.com)</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-04-14T16:58:29.707Z
Answers.LastActivityDate: 2023-04-14T16:58:29.707Z
Answers.UserDisplayName: Justin Young
Body: <p>Emails in CiviMail are bouncing with the following error message:</p>
  <blockquote>
  <p>Failed to set sender: b.17.13.b9ecea4c55fed5e3@example.com [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 Admi</p>
  </blockquote>
  <p>Outbound email settings are good and test emails sent from there work.</p>
  <p>Taking a cue from <a href="https://civicrm.stackexchange.com/questions/7270/civimail-smtp-error-when-sending-test-email">this post</a>, I looked at &quot;Administer - CiviMail - Mail Accounts.&quot;</p>
  <p>When using IMAP there, I get the following error:</p>
  <blockquote>
  <p>An error occured while sending or receiving mail. Failed to connect to
  the server: my.example.com:143. (See log for more details.)</p>
  </blockquote>
  <p>The log is as follows:</p>
  <pre><code>Apr 14 06:41:17  [warning] MailSettings: Failed to establish test connection
  Array
  (
      [exception] =&gt; ezcMailTransportException: &quot;An error occured while sending or receiving mail. Failed to connect to the server: my.example.com:143.&quot;
  #0 /app/data/wp-content/plugins/civicrm/civicrm/vendor/zetacomponents/mail/src/transports/imap/imap_transport.php(403): ezcMailTransportConnection-&gt;__construct()
  #1 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore/Imap.php(58): ezcMailImapTransport-&gt;__construct()
  #2 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore.php(76): CRM_Mailing_MailStore_Imap-&gt;__construct()
  #3 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore.php(53): CRM_Mailing_MailStore::{closure}()
  #4 /app/data/wp-content/plugins/civicrm/civicrm/Civi/Api4/Action/MailSettings/TestConnection.php(28): CRM_Mailing_MailStore::getStore()
  #5 /app/data/wp-content/plugins/civicrm/civicrm/Civi/Api4/Generic/BasicBatchAction.php(92): Civi\Api4\Action\MailSettings\TestConnection-&gt;doTask()
  #6 /app/data/wp-content/plugins/civicrm/civicrm/Civi/Api4/Generic/BasicBatchAction.php(75): Civi\Api4\Generic\BasicBatchAction-&gt;processBatch()
  #7 /app/data/wp-content/plugins/civicrm/civicrm/Civi/Api4/Provider/ActionObjectProvider.php(72): Civi\Api4\Generic\BasicBatchAction-&gt;_run()
  #8 /app/data/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(158): Civi\Api4\Provider\ActionObjectProvider-&gt;invoke()
  #9 /app/data/wp-content/plugins/civicrm/civicrm/Civi/Api4/Generic/AbstractAction.php(250): Civi\API\Kernel-&gt;runRequest()
  #10 /app/data/wp-content/plugins/civicrm/civicrm/api/api.php(85): Civi\Api4\Generic\AbstractAction-&gt;execute()
  #11 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Admin/Form/MailSettings.php(214): civicrm_api4()
  #12 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(573): CRM_Admin_Form_MailSettings-&gt;postProcess()
  #13 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php(152): CRM_Core_Form-&gt;mainProcess()
  #14 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php(119): CRM_Core_QuickForm_Action_Upload-&gt;realPerform()
  #15 /app/data/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Upload-&gt;perform()
  #16 /app/data/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller-&gt;handle()
  #17 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(355): HTML_QuickForm_Page-&gt;handle()
  #18 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php(334): CRM_Core_Controller-&gt;run()
  #19 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php(140): CRM_Core_Page_Basic-&gt;edit()
  #20 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(319): CRM_Core_Page_Basic-&gt;run()
  #21 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(69): CRM_Core_Invoke::runItem()
  #22 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke()
  #23 /app/data/wp-content/plugins/civicrm/civicrm.php(1199): CRM_Core_Invoke::invoke()
  #24 /app/code/wp-includes/class-wp-hook.php(308): CiviCRM_For_WordPress-&gt;invoke()
  #25 /app/code/wp-includes/class-wp-hook.php(332): WP_Hook-&gt;apply_filters()
  #26 /app/code/wp-includes/plugin.php(517): WP_Hook-&gt;do_action()
  #27 /app/code/wp-admin/admin.php(259): do_action()
  #28 {main}
  
  )
  </code></pre>
  <p>(This is not surprising as my server uses a different port for IMAP, but I'm not sure where to change that in CiviCRM.)</p>
  <p>However, the connection succeeds when the Maildir protocol is selected.</p>
  <p>I'm not sure if &quot;Administer - CiviMail - Mail Accounts&quot; has anything to do with the bounces in CiviMail, but any help regarding next steps is appreciated.</p>
  <p>Using CiviCRM 5.57.0 with Wordpress 6.2.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-04-14T15:03:34.297Z
Comments.Text: There is definitely an issue with your inbound server setup. Whether that is also preventing sending is hard for me to say, but it is conceivable. I can't find docs on setting a custom port, but I would try adding it via a colon at the end of the server line like this: `mail.server.com:1234`
Comments.UserDisplayName: kapn
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-04-14T16:57:17.913Z
Comments.Text: Thank you. Adding the port did change the error message which now reads: "An error occured while sending or receiving mail. The connection to the IMAP server is ok, but a negative response from server was received. Try again later. (See log for more details.)"
Comments.UserDisplayName: Justin Young
Tags: <bounce>
Title: CiviMail - Bounces with "Failed to set sender"
ThreadText: # CiviMail - Bounces with "Failed to set sender"
  
  (Asked by: username_0 on 2023-04-14)
  
  Emails in CiviMail are bouncing with the following error message:
  
  > Failed to set sender: b.17.13.b9ecea4c55fed5e3@example.com [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 Admi
  
  Outbound email settings are good and test emails sent from there work.
  
  Taking a cue from [this post](https://civicrm.stackexchange.com/questions/7270/civimail-smtp-error-when-sending-test-email), I looked at "Administer - CiviMail - Mail Accounts."
  
  When using IMAP there, I get the following error:
  
  > An error occured while sending or receiving mail. Failed to connect to
  > the server: my.example.com:143. (See log for more details.)
  
  The log is as follows:
  
  ```
  Apr 14 06:41:17  [warning] MailSettings: Failed to establish test connection
  Array
  (
      [exception] => ezcMailTransportException: "An error occured while sending or receiving mail. Failed to connect to the server: my.example.com:143."
  #0 /app/data/wp-content/plugins/civicrm/civicrm/vendor/zetacomponents/mail/src/transports/imap/imap_transport.php(403): ezcMailTransportConnection->__construct()
  #1 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore/Imap.php(58): ezcMailImapTransport->__construct()
  #2 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore.php(76): CRM_Mailing_MailStore_Imap->__construct()
  #3 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore.php(53): CRM_Mailing_MailStore::{closure}()
  #4 /app/data/wp-content/plugins/civicrm/civicrm/Civi/Api4/Action/MailSettings/TestConnection.php(28): CRM_Mailing_MailStore::getStore()
  #5 /app/data/wp-content/plugins/civicrm/civicrm/Civi/Api4/Generic/BasicBatchAction.php(92): Civi\Api4\Action\MailSettings\TestConnection->doTask()
  #6 /app/data/wp-content/plugins/civicrm/civicrm/Civi/Api4/Generic/BasicBatchAction.php(75): Civi\Api4\Generic\BasicBatchAction->processBatch()
  #7 /app/data/wp-content/plugins/civicrm/civicrm/Civi/Api4/Provider/ActionObjectProvider.php(72): Civi\Api4\Generic\BasicBatchAction->_run()
  #8 /app/data/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(158): Civi\Api4\Provider\ActionObjectProvider->invoke()
  #9 /app/data/wp-content/plugins/civicrm/civicrm/Civi/Api4/Generic/AbstractAction.php(250): Civi\API\Kernel->runRequest()
  #10 /app/data/wp-content/plugins/civicrm/civicrm/api/api.php(85): Civi\Api4\Generic\AbstractAction->execute()
  #11 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Admin/Form/MailSettings.php(214): civicrm_api4()
  #12 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(573): CRM_Admin_Form_MailSettings->postProcess()
  #13 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php(152): CRM_Core_Form->mainProcess()
  #14 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php(119): CRM_Core_QuickForm_Action_Upload->realPerform()
  #15 /app/data/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Upload->perform()
  #16 /app/data/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle()
  #17 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(355): HTML_QuickForm_Page->handle()
  #18 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php(334): CRM_Core_Controller->run()
  #19 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php(140): CRM_Core_Page_Basic->edit()
  #20 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(319): CRM_Core_Page_Basic->run()
  #21 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(69): CRM_Core_Invoke::runItem()
  #22 /app/data/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke()
  #23 /app/data/wp-content/plugins/civicrm/civicrm.php(1199): CRM_Core_Invoke::invoke()
  #24 /app/code/wp-includes/class-wp-hook.php(308): CiviCRM_For_WordPress->invoke()
  #25 /app/code/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
  #26 /app/code/wp-includes/plugin.php(517): WP_Hook->do_action()
  #27 /app/code/wp-admin/admin.php(259): do_action()
  #28 {main}
  
  )
  
  ```
  
  (This is not surprising as my server uses a different port for IMAP, but I'm not sure where to change that in CiviCRM.)
  
  However, the connection succeeds when the Maildir protocol is selected.
  
  I'm not sure if "Administer - CiviMail - Mail Accounts" has anything to do with the bounces in CiviMail, but any help regarding next steps is appreciated.
  
  Using CiviCRM 5.57.0 with Wordpress 6.2.
  
  **Tags:** bounce
  
  > **Comments:**
  > **username_1**: There is definitely an issue with your inbound server setup. Whether that is also preventing sending is hard for me to say, but it is conceivable. I can't find docs on setting a custom port, but I would try adding it via a colon at the end of the server line like this: `mail.server.com:1234`  
  > **username_0**: Thank you. Adding the port did change the error message which now reads: "An error occured while sending or receiving mail. The connection to the IMAP server is ok, but a negative response from server was received. Try again later. (See log for more details.)"  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2023-04-14. Score: 3
  
  Turns out I needed to enable masquerading on my server which "allows users and apps to send emails with an arbitrary username in the FROM address."
  
  I am now able to send through CiviMail.
  
  I thought of this as the tail end of the error message was:
  
  > (code: 550, response: Authenticated user user@example.com cannot send mail as b.17.14.5c9e67488c7c2078@example.com)
  
  
  ---
  
  