Support passing email with display name for To, CC, BCC, Reply-To fields

Created on 16 December 2024, 6 days ago

Problem/Motivation

The \Drupal\sendgrid\SendgridHandler::sendMail() method expects emails set in to, cc, bcc and reply-to keys of the $message argument to be emails formatted as username@domain.com format.
However, that's not always the case as the address may also be formatted as Display Name <username@domain.com>.
This causes validation failure in the SendGrid library:
Error code 0: "$emailAddress" must be a valid email address. Got: Display Name <username@domain.com>

Steps to reproduce

Send an email to the recipient formatted as Display Name <username@domain.com>.

Proposed resolution

Add a helper method parsing the email input string, optionally extracting the display name to be passed to addTo, addC, and other similar methods of the \SendGrid\Mail\Mail class.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine abramm Lutsk

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024