Answers.Body: <p>It looks like <a href="https://github.com/civicrm/civicrm-core/blob/9eca1f7f955428c3f29b9be4eaf8e322af4d2d8d/CRM/Contribute/Form/Contribution/Confirm.php#L1693" rel="nofollow noreferrer">around here</a>, specifically for memberships and depending on the exact details, APIv3 Contribution completetransaction is being used, which includes sending the email, then maybe rolls back the contribution being updates to completed when the email sending fails or something along those lines.</p>
  <p>Seems like a bug to me, I'd log it at <a href="https://lab.civicrm.org/groups/dev/-/issues/" rel="nofollow noreferrer">https://lab.civicrm.org/groups/dev/-/issues/</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-28T16:18:45.917Z
Answers.Text: Thanks. Submitted bug report.
Answers.UserDisplayName: Michael Matthews
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-27T18:27:17.803Z
Answers.LastActivityDate: 2023-08-27T18:27:17.803Z
Answers.UserDisplayName: Lars SG
Answers.Body: <p>Agreed that failing to send emails shouldn't have an effect that disastrous.</p>
  <p>I've seen this occasionally over the years, but never tracked it down.</p>
  <p>A PR to catch errors while sending receipts would be a Good Thing.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-23T13:04:23.243Z
Answers.LastActivityDate: 2023-08-23T13:04:23.243Z
Answers.UserDisplayName: Alan Dixon
Body: <p>On our CiviCRM site, the email servers we were using have been unavailable for several days now. WordPress 6.3, CiviCRM 5.64.0, using WP Mail SMTP plugin to avoid problems with our virtual Linux host being seen as less than ideal to send email from by the various spam protection authorities out there). I noticed that when we could no longer connect to the SMTP provider we were using before, this would cause CiviContribution errors. Transactions still pending, even though payment went through, because it could not send the receipt email. Acknowledging the whole &quot;email should work&quot; resolution, which is being worked on already, is there some way to make sure that the contribution workflow does NOT depend on email servers being reachable, within CiviCRM? The workaround until our mail server issue is resolved was to go back to locally sending mail, so the problem is really in the free version (non-profit, etc.) of WP Mail SMTP never returning, causing the php-fpm timeout. But the contribution itself seems to really want to send that email before it marks the transaction as complete, which I think is a bit backwards. Mark transaction complete and then send email. If the email system throws an error, at least the transaction is done and you can resend the receipt later.</p>
  <p>Make sense? Any way to change the process so it happens in this order?</p>
  <p>Thanks.</p>
  <p>Michael Matthews</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-21T18:53:16.333Z
Comments.Text: I don't think you can use WP Mail SMTP plugin for CiviCRM emails, so it sounds like you maybe have some kind of external form system in use. Can you give details of how these contributions are being processed?
Comments.UserDisplayName: Lars SG
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-27T17:13:11.443Z
Comments.Text: They may not be specifically for CiviCRM emails, but something about having a new member sign up in CiviCRM triggers emails to be sent (one for receipt of transaction, one for WordPress password reset), before the actual credit card contribution is processed. I'm guessing it's the receipt one here. We don't use any sort of external form. When WP Mail SMTP was pointing to an SMTP server that timed out, users could not finish the signup process (incomplete transaction). When I reconfigured WP Mail SMTP to use local mailer, the contribution process at least worked.
Comments.UserDisplayName: Michael Matthews
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-27T18:21:28.733Z
Comments.Text: Oh, interesting, I guess you can use WP Mail SMTP in that way. I would maybe try it with your mailer configured directly in CiviCRM instead of in WP, just to see if that might be an issue. See Administer > System Settings > Outbound Email.
Comments.UserDisplayName: Lars SG
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-28T15:06:44.147Z
Comments.Text: That's what I did to work around the issue, but that just reintroduces the problem of using the local mailer........ looking for a way to not have to do that.
Comments.UserDisplayName: Michael Matthews
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-28T15:18:47.263Z
Comments.Text: Can't you set up the same SMTP account you use in WP Mail SMTP in Outbound Mail in CiviCRM - with select mailer = SMTP?
Comments.UserDisplayName: Lars SG
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-28T16:20:02.293Z
Comments.Text: Given that the SMTP account is what's failing, yes, I could, and I would normally, but, it failed. That's the entire problem here. Timeouts to SMTP connections cause contribution transactions to fail with pending/incomplete after credit card was processed successfully. It's treating the sending of the receipt (or something) as critical to the success of the transaction, which it should not.
Comments.UserDisplayName: Michael Matthews
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-28T16:30:28.327Z
Comments.Text: Yes, I agree with you. I don't think it should make any difference, but given that the way you have it set up is different than usual, I was thinking it might be worthwhile testing without WP Mail SMTP in the mix. Logically, it shouldn't matter, but maybe worth trying.
Comments.UserDisplayName: Lars SG
Tags: <civicontribute><smtp><pending>
Title: Email timeouts breaking contributions?
ThreadText: # Email timeouts breaking contributions?
  
  (Asked by: username_0 on 2023-08-21)
  
  On our CiviCRM site, the email servers we were using have been unavailable for several days now. WordPress 6.3, CiviCRM 5.64.0, using WP Mail SMTP plugin to avoid problems with our virtual Linux host being seen as less than ideal to send email from by the various spam protection authorities out there). I noticed that when we could no longer connect to the SMTP provider we were using before, this would cause CiviContribution errors. Transactions still pending, even though payment went through, because it could not send the receipt email. Acknowledging the whole "email should work" resolution, which is being worked on already, is there some way to make sure that the contribution workflow does NOT depend on email servers being reachable, within CiviCRM? The workaround until our mail server issue is resolved was to go back to locally sending mail, so the problem is really in the free version (non-profit, etc.) of WP Mail SMTP never returning, causing the php-fpm timeout. But the contribution itself seems to really want to send that email before it marks the transaction as complete, which I think is a bit backwards. Mark transaction complete and then send email. If the email system throws an error, at least the transaction is done and you can resend the receipt later.
  
  Make sense? Any way to change the process so it happens in this order?
  
  Thanks.
  
  username_0
  
  **Tags:** civicontribute, smtp, pending
  
  > **Comments:**
  > **username_1**: I don't think you can use WP Mail SMTP plugin for CiviCRM emails, so it sounds like you maybe have some kind of external form system in use. Can you give details of how these contributions are being processed?  
  > **username_0**: They may not be specifically for CiviCRM emails, but something about having a new member sign up in CiviCRM triggers emails to be sent (one for receipt of transaction, one for WordPress password reset), before the actual credit card contribution is processed. I'm guessing it's the receipt one here. We don't use any sort of external form. When WP Mail SMTP was pointing to an SMTP server that timed out, users could not finish the signup process (incomplete transaction). When I reconfigured WP Mail SMTP to use local mailer, the contribution process at least worked.  
  > **username_1**: Oh, interesting, I guess you can use WP Mail SMTP in that way. I would maybe try it with your mailer configured directly in CiviCRM instead of in WP, just to see if that might be an issue. See Administer > System Settings > Outbound Email.  
  > **username_0**: That's what I did to work around the issue, but that just reintroduces the problem of using the local mailer........ looking for a way to not have to do that.  
  > **username_1**: Can't you set up the same SMTP account you use in WP Mail SMTP in Outbound Mail in CiviCRM - with select mailer = SMTP?  
  > **username_0**: Given that the SMTP account is what's failing, yes, I could, and I would normally, but, it failed. That's the entire problem here. Timeouts to SMTP connections cause contribution transactions to fail with pending/incomplete after credit card was processed successfully. It's treating the sending of the receipt (or something) as critical to the success of the transaction, which it should not.  
  > **username_1**: Yes, I agree with you. I don't think it should make any difference, but given that the way you have it set up is different than usual, I was thinking it might be worthwhile testing without WP Mail SMTP in the mix. Logically, it shouldn't matter, but maybe worth trying.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2023-08-27. Score: 1
  
  It looks like [around here](https://github.com/civicrm/civicrm-core/blob/9eca1f7f955428c3f29b9be4eaf8e322af4d2d8d/CRM/Contribute/Form/Contribution/Confirm.php#L1693), specifically for memberships and depending on the exact details, APIv3 Contribution completetransaction is being used, which includes sending the email, then maybe rolls back the contribution being updates to completed when the email sending fails or something along those lines.
  
  Seems like a bug to me, I'd log it at <https://lab.civicrm.org/groups/dev/-/issues/>.
  
  > **Comments:**
  > **username_0**: Thanks. Submitted bug report.  
  
  ---
  
  ### Answer by username_2 on 2023-08-23. Score: 0
  
  Agreed that failing to send emails shouldn't have an effect that disastrous.
  
  I've seen this occasionally over the years, but never tracked it down.
  
  A PR to catch errors while sending receipts would be a Good Thing.
  
  
  ---
  
  