craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.27k stars 635 forks source link

[3.x]: Error sending email, got code "554" #11175

Closed development-lameco closed 2 years ago

development-lameco commented 2 years ago

What happened?

Description

So we currently having this problem with sending the account related emails. On my local environment using Mailhog I receive the mails without any issues. But on our staging environment we get the following error message in de web.log file:

Error sending email: Expected response code 354 but got code "554", with message "554 5.5.1 Error: no valid recipients

Testing the Mail settings it does send the mail without problem so I'm guessing it has something to do only related to account mails?

Steps to reproduce

  1. n/a.

Expected behavior

Email successfully send and received by the email in the account.

Actual behavior

Error sending email: Expected response code 354 but got code "554", with message "554 5.5.1 Error: no valid recipients

Craft CMS version

3.7.41

PHP version

8.1

Operating system and version

Linux 5.4.0-109-generic

Database type and version

MySQL 10.6.7

Image driver and version

Imagick 3.7.0 (ImageMagick 7.1.0-24)

Installed plugins and versions

"born05/craft-twofactorauthentication": "2.10.0",
"craftcms/cms": "3.7.41",
"craftcms/element-api": "2.8.5",
"craftcms/redactor": "2.10.8",
"enupal/translate": "2.3.0",
"geoip2/geoip2": "~2.0",
"marionnewlevant/snitch": "3.0.4.1",
"nystudio107/craft-retour": "3.1.71",
"nystudio107/craft-seomatic": "3.4.30",
"nystudio107/craft-vite": "1.0.24",
"putyourlightson/craft-blitz": "3.12.4",
"sebastianlenz/linkfield": "1.0.25",
"spicyweb/craft-embedded-assets": "2.10.7",
"spicyweb/craft-neo": "2.13.9",
"topshelfcraft/environment-label": "3.2.0",
"verbb/field-manager": "2.2.4",
"verbb/formie": "1.5.16",
"verbb/knock-knock": "1.2.16",
"verbb/navigation": "1.4.26",
"verbb/super-table": "2.7.1",
angrybrad commented 2 years ago

554 5.5.1 Error: no valid recipients

Does the email address actually exist you're trying to send to? You can test by sending an email to it from outside of Craft via your preferred email client.

If so, what email method are you using under Settings->Email in Craft?

development-lameco commented 2 years ago

Yes, as I mentioned using the Test mail functionality in dev mode works as expected. Also the email address for the account is a valid email address.

angrybrad commented 2 years ago

as I mentioned using the Test mail functionality in dev mode works as expected.

I'm taking PHP and Craft out of the equation and asking if you can successfully send an email to that address through a standalone email client.

Also:

If so, what email method are you using under Settings->Email in Craft?

development-lameco commented 2 years ago

Sorry for my late reply, but yes sending email with a standalone email client to that address works.

angrybrad commented 2 years ago

What email method are you using under Settings->Email in Craft? SMTP? sendmail? something else?

development-lameco commented 2 years ago

SMTP, we use Mandrill. Using port 465 and ssl encryption method.

twosixcode commented 2 years ago

I just bumped into this, too. Same error message, same condition where the test email sends just fine. Also Mandrill SMTP.

Did you figure anything out @development-lameco ?

development-lameco commented 2 years ago

@twosixcode unfortunately not. Although I need to confirm if it also happens on other Craft instances we are running, it might be a specific instance issue as far as I know.

EDIT: I tried it on another instance using the same configuration, except an older Craft version (3.7.35) and works without any issue which makes it even more strange i guess.

development-lameco commented 2 years ago

Ok so after some more testing on various instances I think I found the culprit. We've set up the Email settings to all come from the .env file except the fromName. But somehow the $EMAIL_AUTHENTICATION was missing in the .env file and sometimes messes with sending the mail.

email:
  fromEmail: $EMAIL_FROM
  fromName: Lameco
  replyToEmail: null
  template: ''
  transportSettings:
    encryptionMethod: $EMAIL_ENCRYPTION
    host: $EMAIL_HOST
    password: $EMAIL_PASSWORD
    port: $EMAIL_PORT
    timeout: '10'
    useAuthentication: $EMAIL_AUTHENTICATION
    username: $EMAIL_USER
  transportType: craft\mail\transportadapters\Smtp

Can you confirm this @twosixcode ?

twosixcode commented 2 years ago

In this instance we're not using .env variables for the email settings, but I took a look and we did have a blank "Reply-To Address" field. This is an optional field, and leaving it blank definitely did not cause issue with the Email Settings "Test" email being sent. But based on your comment @development-lameco I went ahead and entered the email we're using for System Email Address just as a test and the forgot password emails are sending now.

Thanks for sharing your findings!

development-lameco commented 2 years ago

Weird that it can have different causes. As you can see in the piece of config we mostly leave it blank. But glad I gave you a nudge in the right direction.