‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Utility\MailUtility Class Reference

Static Public Member Functions

static string null getSystemFromName ()
 
static string getSystemFromAddress ()
 
static string breakLinesForEmail (string $str, string $newlineChar=LF, int $lineWidth=76)
 
static array parseAddresses (string $rawAddresses)
 

Public Attributes

 return [$address]
 
 else
 
return $replyTo
 

Static Public Attributes

static array< string|int, function getSystemFrom():?array { $address=self::getSystemFromAddress();$name=self::getSystemFromName();if(! $address) { return null;} if( $name) { return[ $address=> $name
 
static array< string|int, function getSystemReplyTo():array { $mailConfiguration=$GLOBALS[ 'TYPO3_CONF_VARS'][ 'MAIL'] ??[];$replyToAddress=$mailConfiguration[ 'defaultMailReplyToAddress'] ?? null;if(empty( $replyToAddress)||!GeneralUtility::validEmail( $replyToAddress)) { return[];} if(!empty( $mailConfiguration[ 'defaultMailReplyToName'])) { $replyTo=[ $replyToAddress=> $mailConfiguration ['defaultMailReplyToName']
 

Detailed Description

Class to handle mail specific functionality

Definition at line 25 of file MailUtility.php.

Member Function Documentation

◆ breakLinesForEmail()

static string TYPO3\CMS\Core\Utility\MailUtility::breakLinesForEmail ( string  $str,
string  $newlineChar = LF,
int  $lineWidth = 76 
)
static

◆ getSystemFromAddress()

static string TYPO3\CMS\Core\Utility\MailUtility::getSystemFromAddress ( )
static

Creates a valid email address for the sender of mail messages.

Uses a fallback chain: $TYPO3_CONF_VARS['MAIL']['defaultMailFromAddress'] -> no-reply@FirstDomainRecordFound -> no-reply@php_uname('n') -> no-re.nosp@m.ply@.nosp@m.examp.nosp@m.le.c.nosp@m.om

Ready to be passed to $mail->setFrom()

Returns
‪string An email address

Definition at line 79 of file MailUtility.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Install\Authentication\AuthenticationService\getSenderEmailAddress(), TYPO3\CMS\Linkvalidator\Task\ValidatorTask\loadModTSconfig(), and TYPO3\CMS\Core\Mail\Mailer\send().

◆ getSystemFromName()

static string null TYPO3\CMS\Core\Utility\MailUtility::getSystemFromName ( )
static

Creates a valid "from" name for mail messages.

As configured in Install Tool.

Returns
‪string|null The name (unquoted, unformatted). NULL if none is set or an invalid non-string value.

Definition at line 59 of file MailUtility.php.

References $GLOBALS, and TYPO3\CMS\Core\Utility\MailUtility\$name.

Referenced by TYPO3\CMS\Install\Authentication\AuthenticationService\getSenderEmailName(), TYPO3\CMS\Linkvalidator\Task\ValidatorTask\loadModTSconfig(), and TYPO3\CMS\Core\Mail\Mailer\send().

◆ parseAddresses()

static array TYPO3\CMS\Core\Utility\MailUtility::parseAddresses ( string  $rawAddresses)
static

Parses mailbox headers and turns them into an array.

Mailbox headers are a comma separated list of 'name email.nosp@m.@exa.nosp@m.mple..nosp@m.org' combinations or plain email addresses (or a mix of these). The resulting array has key-value pairs where the key is either a number (no display name in the mailbox header) and the value is the email address, or the key is the email address and the value is the display name.

Parameters
string$rawAddresses‪Comma separated list of email addresses (optionally with display name)
Returns
‪array Parsed list of addresses.

Definition at line 183 of file MailUtility.php.

Referenced by TYPO3\CMS\Core\Tests\Unit\Utility\MailUtilityTest\parseAddressesTest().

Member Data Documentation

◆ $mailConfiguration

array<string|int, function getSystemReplyTo(): array { $mailConfiguration = $GLOBALS['TYPO3_CONF_VARS']['MAIL'] ?? []; $replyToAddress = $mailConfiguration['defaultMailReplyToAddress'] ?? null; if (empty($replyToAddress) || !GeneralUtility::validEmail($replyToAddress)) { return []; } if (!empty($mailConfiguration['defaultMailReplyToName'])) { $replyTo = [$replyToAddress => TYPO3\CMS\Core\Utility\MailUtility::$mailConfiguration[ 'defaultMailReplyToName']
static

Gets a default "reply-to" for mail messages (email and name).

Ready to be passed to $mail->setReplyTo()

This method returns a list of email addresses, but depending on the existence of "defaultMailReplyToName" the array can have a different shape:

  1. ‪An assoc. array: key => a valid reply-to address which can be used as sender; value => a valid reply-to name which can be used as a sender
  2. ‪A numeric array with one entry: a valid reply-to address which can be used as sender
Returns
‪array<string|int, string>

Definition at line 116 of file MailUtility.php.

◆ $name

array<string|int, function getSystemFrom(): ?array { $address = self::getSystemFromAddress(); $name = self::getSystemFromName(); if (!$address) { return null; } if ($name) { return [$address => TYPO3\CMS\Core\Utility\MailUtility::$name
static

Gets a valid "from" for mail messages (email and name).

Ready to be passed to $mail->setFrom()

This method can return three different variants:

  1. ‪An assoc. array: key => Valid email address which can be used as sender; value => Valid name which can be used as a sender
  2. ‪A numeric array with one entry: Valid email address which can be used as sender
  3. ‪Null, if no address is configured
Returns
‪array<string|int, string>|null

Definition at line 47 of file MailUtility.php.

Referenced by TYPO3\CMS\Core\Utility\MailUtility\getSystemFromName().

◆ $replyTo

return TYPO3\CMS\Core\Utility\MailUtility::$replyTo

Definition at line 121 of file MailUtility.php.

◆ else

TYPO3\CMS\Core\Utility\MailUtility::else
Initial value:
{
‪$replyTo = [$replyToAddress]

Definition at line 117 of file MailUtility.php.

◆ return

TYPO3\CMS\Core\Utility\MailUtility::return[ $address]

Definition at line 49 of file MailUtility.php.

‪TYPO3\CMS\Core\Utility\MailUtility\$replyTo
‪return $replyTo
Definition: MailUtility.php:121