craftcms / commerce

Fully integrated ecommerce for Craft CMS.
https://craftcms.com/commerce
Other
217 stars 170 forks source link

[5.x]: Commerce can't send emails, system email test works #3596

Closed turnstylerj closed 2 weeks ago

turnstylerj commented 1 month ago

What happened?

Description

When testing an email send via Craft's Email section settings, it's able to successfully send (via SMTP credentials): 2024-07-23 at 16 23 13 2024-07-23 at 16 23 06

We noticed order confirmation emails weren't coming through; if I go to Commerce > Orders and select the order in question, then trigger an email send manually, the loading icon just hangs and I get a console error.

2024-07-23 at 16 23 41 2024-07-23 at 16 23 54 2024-07-23 at 16 28 28

Craft CMS version

5.2.8

Craft Commerce version

5.0.13

PHP version

8.2.20

Operating system and version

Linux 6.5.0-15-generic

Database type and version

MySQL 8.0.33

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.11-60)

Installed plugins and versions

CKEditor 4.1.0 Colour Swatches 5.0.2 Control Panel CSS 3.0.0 Cookies 5.0.0 Craft Commerce 5.0.13 Default Dashboard 3.0.1 Element Relations 3.0.4 Field Manager 4.0.2 GeoMate 3.0.0-beta.2 ImageOptimize 5.0.2 Image Resizer 4.0.0 Multi Translator 2.6.0 Neo 5.0.5 No-Cache 3.0.2 PayPal Checkout for Craft Commerce 3.0.1 Redirects 5.0.2 Retcon 3.2.0 SEO 5.1.1 Servd Assets and Helpers 4.0.5 Stripe for Craft Commerce 5.0.1.1

linear[bot] commented 1 month ago

PT-1992 [5.x]: Commerce can't send emails, system email test works

turnstylerj commented 1 month ago

Random additional FYI that when I filed this issue, I received a "Run failed" email that led me to this error:

2024-07-23 at 16 32 30

lukeholder commented 1 month ago

@turnstylerj I cant reproduce this, my emails are sending successfully from the order admin screen. Could you look into your logs, my guess is there is a template error. Let us know or send the logs to support@craftcms.com and mention this issue number. Thanks.

turnstylerj commented 1 month ago

Brad figured out what was going on here via support email!

Pretty sure this is a bug in Commerce.

Try this on your staging site and see if it works:

Go to admin/commerce/settings/emails/primaryStore/1?site=english, and instead of relying on the "global" env vars for Status Email Address and From name, explicitly put in $SMTP_SYSTEM_EMAIL and $SMTP_SENDER_NAME, then save and see if you can reproduce the issue.

After explicitly setting those env vars, it works. Looks like Commerce needs to account for the correct defaults if the fields aren't filled out.

nfourtythree commented 2 weeks ago

Hi @turnstylerj

Thank you for bringing this to our attention and following up on it.

We have pushed a fix for this issue which will be included in the next release of Commerce 5.x.

To get this early, change your craftcms/commerce requirement in your project's composer.json to:

"require": {
  "craftcms/commerce": "5.x-dev#e66113e65195123f5916ff00302d94023236d27c as 5.0.16.2",
  "...": "..."
}

Then run composer update.

Thanks!