$emailAddress must be a valid email address

Created on 4 October 2024, 3 months ago

Problem/Motivation

Using the latest version of Sendgrid with Drupal Core 10.3, this issue still exists. It was seemingly patched a year or so ago, but the issue still remains and it prevents any emails at all from being sent. (Even system emails). Even the test sendgrid email fails with the following error:

The website encountered an unexpected error. Try again later.

SendGrid\Exception\TypeException: "$emailAddress" must be a valid email address. Got: in SendGrid\Helper\Assert::email() (line 68 of /home/jfurnas/sites/lms/vendor/fastglass/sendgrid/src/Helper/Assert.php).

I attempted to use the 'send test sendgrid email' for some debugging, and found this:

If I print $emailAddress in the setEmailAddress method in the fastglass/sendgrid/src/Mail/EmailAddress.php file, it prints it as email@test.comemail@test.comemail@test.com (with no spaces and no commas).

Steps to reproduce

Enable sendgrid integration. Set sendgrid up to be your mail sender. Send any email (including system mails).

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jfurnas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jfurnas
  • πŸ‡ΊπŸ‡ΈUnited States ja09

    Same issue here ever since upgrading from d9 to d10. I've tried many versions of this module and the patch from the parent issue with no luck.

  • πŸ‡ΊπŸ‡ΈUnited States jfurnas

    @ja09 That's correct. I can send the sendgrid test email, and all of the default system emails (password resets, etc) all go through, but any other emails not generated by Drupal core (like from other modules, or from custom modules), all throw the same error.

    I did some debugging, and I temporarily added a print statement where the Assertion happens at (in vendor/fastglass/sendgrid/src/Mail/emailAddress.php), and it's printing the email address field twice, with no space and no commas between them. (e.g. test@example.comtest@example.com) on the PHP error page.

Production build 0.71.5 2024