class Mail (View source)

Provides helpers to ensure emails are compliant with RFCs.

Constants

RFC_2822_SPECIALS

RFC-2822 "specials" characters.

Methods

static string
formatDisplayName(string $string) deprecated

Return a RFC-2822 compliant "display-name" component.

Details

static string formatDisplayName(string $string) deprecated

deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Mime\Header\MailboxHeader instead.

Return a RFC-2822 compliant "display-name" component.

The "display-name" component is used in mail header "Originator" fields (From, Sender, Reply-to) to give a human-friendly description of the address, i.e. From: My Display Name xyz@example.org. RFC-822 and RFC-2822 define its syntax and rules. This method gets as input a string to be used as "display-name" and formats it to be RFC compliant.

Parameters

string $string

A string to be used as "display-name".

Return Value

string

A RFC compliant version of the string, ready to be used as "display-name" in mail originator header fields.

See also

https://www.drupal.org/node/3207439