oroinc / platform

Main OroPlatform package with core functionality.
Other
627 stars 351 forks source link

OroEmailBundle can't send email with Amazon SES #1094

Open jimohalloran opened 1 year ago

jimohalloran commented 1 year ago

Summary
After instaling the symfony/amazon-mailer package and configuring the mailer_dsn (tried the ses://, ses+https:// and ses+api:// schemes), OroCRM is unable to send the new user invitation email successfully. The UI shows both User saved. and An invitation email sending was failed, but there is an RfcComplianceException in the logs:

app.ERROR: Invitation email sending failed. {"exception":"[object] (Symfony\\Component\\Mime\\Exception\\RfcComplianceException(code: 0): Email \"01080185f0f5aa0b-56ed55a5-a3f1-42ef-b5df-ff3744d8cf2b-000000\" does not comply with addr-spec of RFC 2822. at /var/www/html/oro/vendor/symfony/mime/Address.php:56)"} []

The user receives the email, the issue is the failure that appears in the UI and the exception in the logs.

Steps to reproduce
Install an unmodified OroCRM 5.0.x application. Configure to use Amazon SES. Add a new user and attempt to send the invitation email.

Actual Result The new user receives the email, but there is an error message displayed in the UI, and a RfcComplianceException in the logs.

Expected Result
The new user receives the email, and no error is shown in the UI, nor is the RfcComplianceException logged.

Details about your environment

Additional information
Doing some debugging around the exception leads me to think this is at least partially an Oro Platform issue. After the email is sent Oro Platform (Oro/Bundle/EmailBundle/Mailer/Mailer.php:32) gets the MessageID from the sent message and assign it to the Id header of the message entity. This fails because the SES transport returns a temporary ID generated by Symfony, not an email address like string (the actual MessageID). This then fails validation, and the exception is thrown.

Seems like not all message transports are created equal, some some don't return the actual MessageID, but Oro is assuming they do. (See: https://github.com/symfony/symfony/issues/33681) That issue mentions specifically not using the SMTP transport for SWS, but I'm having issues with all of the schemes as you can see above.

So it seems like SES + Oro Platform can't possibly work as is. Seems hard to believe that no one uses Oro Platform + SES with Symfony Mailer, but the two seem fundamentally incompatible as is.

jimohalloran commented 1 year ago

SendGrid with the sendgrid+api:// scheme has the same issue as well. A temporary MessageID is returned that does not look like an email address, therefore the exception is raised even though the email is sent.