MailHeader uses ConstantsTrait, AuthenticationHeaderTrait, DestinationHeaderTrait, IdentificationHeaderTrait, InformationalHeaderTrait, ListHeaderTrait, MimeHeaderTrait, MiscHeaderTrait, NotificationHeaderTrait, OriginatorHeaderTrait, PriorityHeaderTrait, ResentHeaderTrait, TraceHeaderTrait
Enumeration of standard email header field names (RFC 5322 and friends).
The constants preserve the canonical wire-format casing from the relevant
RFCs (5322, 2045, 2369/2919/8058, 6376, 8601, 8617, 8098, 3834). They are
organised by domain into composable traits living in
headers; this class simply uses them all and
adds helper methods. Use a single category trait directly when you only
need part of the set.
Unlike HttpHeader — whose helpers act on the
PHP response sink (headers_list() / header()) — email is built in
memory, so the helpers here operate on an in-memory header map
(array<string,string>). Lookups are case-insensitive per RFC 5322 §2.2:
$headers = MailHeader::set( [] , MailHeader::SUBJECT , 'Hello' ) ;
MailHeader::has( $headers , 'subject' ) ; // true (case-insensitive)
MailHeader::get( $headers , 'SUBJECT' ) ; // 'Hello'
MailHeader::normalize( 'message-id' ) ; // 'Message-ID'
MailHeader::canRepeat( MailHeader::RECEIVED ) ; // true
The ConstantsTrait utilities remain available:
MailHeader::enums()returns all header namesMailHeader::includes('Subject')checks existence (exact, case-sensitive)MailHeader::getConstant('Subject')returns the constant name
Tags
Table of Contents
Constants
- ARC_AUTHENTICATION_RESULTS : string = 'ARC-Authentication-Results'
- `ARC-Authentication-Results` — ARC authentication results (RFC 8617; may repeat).
- ARC_MESSAGE_SIGNATURE : string = 'ARC-Message-Signature'
- `ARC-Message-Signature` — ARC message signature (RFC 8617; may repeat).
- ARC_SEAL : string = 'ARC-Seal'
- `ARC-Seal` — Authenticated Received Chain seal (RFC 8617; may repeat).
- AUTHENTICATION_RESULTS : string = 'Authentication-Results'
- `Authentication-Results` — SPF/DKIM/DMARC results recorded by a receiver (RFC 8601; may repeat).
- AUTO_SUBMITTED : string = 'Auto-Submitted'
- `Auto-Submitted` — Marks automatically generated messages to prevent loops (RFC 3834).
- BCC : string = 'Bcc'
- `Bcc` — Blind carbon-copy recipient(s); removed before delivery.
- CC : string = 'Cc'
- `Cc` — Carbon-copy recipient(s).
- COMMENTS : string = 'Comments'
- `Comments` — Additional comments on the message body (may repeat).
- CONTENT_DESCRIPTION : string = 'Content-Description'
- `Content-Description` — Human-readable description of a body part.
- CONTENT_DISPOSITION : string = 'Content-Disposition'
- `Content-Disposition` — Presentation of a part (`inline` / `attachment`).
- CONTENT_ID : string = 'Content-ID'
- `Content-ID` — Unique identifier of a body part (for `cid:` references).
- CONTENT_LANGUAGE : string = 'Content-Language'
- `Content-Language` — Natural language(s) of the content (RFC 3282).
- CONTENT_LOCATION : string = 'Content-Location'
- `Content-Location` — URI for the content of a part (RFC 2557).
- CONTENT_TRANSFER_ENCODING : string = 'Content-Transfer-Encoding'
- `Content-Transfer-Encoding` — Encoding applied to the body (`base64`, `quoted-printable`, …).
- CONTENT_TYPE : string = 'Content-Type'
- `Content-Type` — Media type of the body / part (e.g. `text/html; charset=utf-8`).
- DATE : string = 'Date'
- `Date` — Origination date of the message (RFC 5322 §3.6.1).
- DISPOSITION_NOTIFICATION_OPTIONS : string = 'Disposition-Notification-Options'
- `Disposition-Notification-Options` — Parameters governing the requested MDN (RFC 8098).
- DISPOSITION_NOTIFICATION_TO : string = 'Disposition-Notification-To'
- `Disposition-Notification-To` — Requests a read receipt (MDN) to this address (RFC 8098).
- DKIM_SIGNATURE : string = 'DKIM-Signature'
- `DKIM-Signature` — DomainKeys Identified Mail signature (RFC 6376; may repeat).
- ERRORS_TO : string = 'Errors-To'
- `Errors-To` — Legacy address for delivery-error reports (superseded by Return-Path).
- FROM : string = 'From'
- `From` — Author(s) of the message (RFC 5322 §3.6.2).
- IMPORTANCE : string = 'Importance'
- `Importance` — Importance hint (`high` / `normal` / `low`) (RFC 4021).
- IN_REPLY_TO : string = 'In-Reply-To'
- `In-Reply-To` — Message-ID(s) of the message(s) this one replies to.
- KEYWORDS : string = 'Keywords'
- `Keywords` — Comma-separated list of keywords / phrases (may repeat).
- LIST_ARCHIVE : string = 'List-Archive'
- `List-Archive` — URL(s) of the list archive (RFC 2369).
- LIST_HELP : string = 'List-Help'
- `List-Help` — URL(s) for help about the list (RFC 2369).
- LIST_ID : string = 'List-Id'
- `List-Id` — Stable identifier of the mailing list (RFC 2919).
- LIST_OWNER : string = 'List-Owner'
- `List-Owner` — Contact of the list owner (RFC 2369).
- LIST_POST : string = 'List-Post'
- `List-Post` — URL(s) / mailto to post to the list (RFC 2369).
- LIST_SUBSCRIBE : string = 'List-Subscribe'
- `List-Subscribe` — URL(s) / mailto to join the list (RFC 2369).
- LIST_UNSUBSCRIBE : string = 'List-Unsubscribe'
- `List-Unsubscribe` — URL(s) / mailto to leave the list (RFC 2369).
- LIST_UNSUBSCRIBE_POST : string = 'List-Unsubscribe-Post'
- `List-Unsubscribe-Post` — Enables one-click unsubscribe (RFC 8058).
- MESSAGE_ID : string = 'Message-ID'
- `Message-ID` — Unique identifier of this message.
- MIME_VERSION : string = 'MIME-Version'
- `MIME-Version` — Declares the MIME version used (always `1.0`).
- ORGANIZATION : string = 'Organization'
- `Organization` — Organization of the sender.
- ORIGINAL_MESSAGE_ID : string = 'Original-Message-ID'
- `Original-Message-ID` — Message-ID of the message a notification refers to.
- PRECEDENCE : string = 'Precedence'
- `Precedence` — Legacy hint (`bulk` / `list` / `junk`) used to suppress auto-replies.
- PRIORITY : string = 'Priority'
- `Priority` — Processing priority (`urgent` / `normal` / `non-urgent`) (RFC 2156).
- RECEIVED : string = 'Received'
- `Received` — Trace of an MTA that handled the message (may repeat).
- RECEIVED_SPF : string = 'Received-SPF'
- `Received-SPF` — Result of an SPF check performed by a receiver (RFC 7208).
- REFERENCES : string = 'References'
- `References` — Message-ID(s) identifying the conversation thread.
- REPLY_TO : string = 'Reply-To'
- `Reply-To` — Mailbox(es) to which replies should be sent.
- RESENT_BCC : string = 'Resent-Bcc'
- `Resent-Bcc` — Blind carbon-copy recipient(s) of the resending.
- RESENT_CC : string = 'Resent-Cc'
- `Resent-Cc` — Carbon-copy recipient(s) of the resending.
- RESENT_DATE : string = 'Resent-Date'
- `Resent-Date` — Date the message was resent.
- RESENT_FROM : string = 'Resent-From'
- `Resent-From` — Author(s) of the resending.
- RESENT_MESSAGE_ID : string = 'Resent-Message-ID'
- `Resent-Message-ID` — Unique identifier of the resending.
- RESENT_SENDER : string = 'Resent-Sender'
- `Resent-Sender` — Agent responsible for the resending.
- RESENT_TO : string = 'Resent-To'
- `Resent-To` — Primary recipient(s) of the resending.
- RETURN_PATH : string = 'Return-Path'
- `Return-Path` — Reverse-path (envelope sender) recorded at final delivery.
- RETURN_RECEIPT_TO : string = 'Return-Receipt-To'
- `Return-Receipt-To` — Legacy, non-standard read-receipt request.
- SENDER : string = 'Sender'
- `Sender` — Mailbox of the agent responsible for the actual transmission.
- SENSITIVITY : string = 'Sensitivity'
- `Sensitivity` — Privacy hint (`Personal` / `Private` / `Company-Confidential`) (RFC 2156).
- SUBJECT : string = 'Subject'
- `Subject` — Topic of the message.
- TO : string = 'To'
- `To` — Primary recipient(s) of the message.
- X_MAILER : string = 'X-Mailer'
- `X-Mailer` — Software that generated the message.
- X_PRIORITY : string = 'X-Priority'
- `X-Priority` — Legacy numeric priority `1` (highest) to `5` (lowest).
Methods
- all() : array<string, string>
- Returns a copy of the header map with every key rewritten to its canonical casing (see {@see self::normalize()}).
- canRepeat() : bool
- Whether a header may legitimately appear more than once in a message (trace fields, resent blocks, signatures, free-form comments…).
- get() : string|null
- Returns the value of a header, looked up case-insensitively.
- has() : bool
- Checks whether a header is present, case-insensitively.
- normalize() : string
- Returns the canonical wire-format casing of a header name.
- remove() : array<string, string>
- Returns a copy of the map with every case-insensitive occurrence of a header removed.
- set() : array<string, string>
- Returns a copy of the map with the header set to a single value, using canonical casing and replacing any previous case-insensitive occurrence.
Constants
ARC_AUTHENTICATION_RESULTS
`ARC-Authentication-Results` — ARC authentication results (RFC 8617; may repeat).
public
string
ARC_AUTHENTICATION_RESULTS
= 'ARC-Authentication-Results'
ARC_MESSAGE_SIGNATURE
`ARC-Message-Signature` — ARC message signature (RFC 8617; may repeat).
public
string
ARC_MESSAGE_SIGNATURE
= 'ARC-Message-Signature'
ARC_SEAL
`ARC-Seal` — Authenticated Received Chain seal (RFC 8617; may repeat).
public
string
ARC_SEAL
= 'ARC-Seal'
AUTHENTICATION_RESULTS
`Authentication-Results` — SPF/DKIM/DMARC results recorded by a receiver (RFC 8601; may repeat).
public
string
AUTHENTICATION_RESULTS
= 'Authentication-Results'
AUTO_SUBMITTED
`Auto-Submitted` — Marks automatically generated messages to prevent loops (RFC 3834).
public
string
AUTO_SUBMITTED
= 'Auto-Submitted'
BCC
`Bcc` — Blind carbon-copy recipient(s); removed before delivery.
public
string
BCC
= 'Bcc'
CC
`Cc` — Carbon-copy recipient(s).
public
string
CC
= 'Cc'
COMMENTS
`Comments` — Additional comments on the message body (may repeat).
public
string
COMMENTS
= 'Comments'
CONTENT_DESCRIPTION
`Content-Description` — Human-readable description of a body part.
public
string
CONTENT_DESCRIPTION
= 'Content-Description'
CONTENT_DISPOSITION
`Content-Disposition` — Presentation of a part (`inline` / `attachment`).
public
string
CONTENT_DISPOSITION
= 'Content-Disposition'
CONTENT_ID
`Content-ID` — Unique identifier of a body part (for `cid:` references).
public
string
CONTENT_ID
= 'Content-ID'
CONTENT_LANGUAGE
`Content-Language` — Natural language(s) of the content (RFC 3282).
public
string
CONTENT_LANGUAGE
= 'Content-Language'
CONTENT_LOCATION
`Content-Location` — URI for the content of a part (RFC 2557).
public
string
CONTENT_LOCATION
= 'Content-Location'
CONTENT_TRANSFER_ENCODING
`Content-Transfer-Encoding` — Encoding applied to the body (`base64`, `quoted-printable`, …).
public
string
CONTENT_TRANSFER_ENCODING
= 'Content-Transfer-Encoding'
CONTENT_TYPE
`Content-Type` — Media type of the body / part (e.g. `text/html; charset=utf-8`).
public
string
CONTENT_TYPE
= 'Content-Type'
DATE
`Date` — Origination date of the message (RFC 5322 §3.6.1).
public
string
DATE
= 'Date'
DISPOSITION_NOTIFICATION_OPTIONS
`Disposition-Notification-Options` — Parameters governing the requested MDN (RFC 8098).
public
string
DISPOSITION_NOTIFICATION_OPTIONS
= 'Disposition-Notification-Options'
DISPOSITION_NOTIFICATION_TO
`Disposition-Notification-To` — Requests a read receipt (MDN) to this address (RFC 8098).
public
string
DISPOSITION_NOTIFICATION_TO
= 'Disposition-Notification-To'
DKIM_SIGNATURE
`DKIM-Signature` — DomainKeys Identified Mail signature (RFC 6376; may repeat).
public
string
DKIM_SIGNATURE
= 'DKIM-Signature'
ERRORS_TO
`Errors-To` — Legacy address for delivery-error reports (superseded by Return-Path).
public
string
ERRORS_TO
= 'Errors-To'
FROM
`From` — Author(s) of the message (RFC 5322 §3.6.2).
public
string
FROM
= 'From'
IMPORTANCE
`Importance` — Importance hint (`high` / `normal` / `low`) (RFC 4021).
public
string
IMPORTANCE
= 'Importance'
IN_REPLY_TO
`In-Reply-To` — Message-ID(s) of the message(s) this one replies to.
public
string
IN_REPLY_TO
= 'In-Reply-To'
KEYWORDS
`Keywords` — Comma-separated list of keywords / phrases (may repeat).
public
string
KEYWORDS
= 'Keywords'
LIST_ARCHIVE
`List-Archive` — URL(s) of the list archive (RFC 2369).
public
string
LIST_ARCHIVE
= 'List-Archive'
LIST_HELP
`List-Help` — URL(s) for help about the list (RFC 2369).
public
string
LIST_HELP
= 'List-Help'
LIST_ID
`List-Id` — Stable identifier of the mailing list (RFC 2919).
public
string
LIST_ID
= 'List-Id'
LIST_OWNER
`List-Owner` — Contact of the list owner (RFC 2369).
public
string
LIST_OWNER
= 'List-Owner'
LIST_POST
`List-Post` — URL(s) / mailto to post to the list (RFC 2369).
public
string
LIST_POST
= 'List-Post'
LIST_SUBSCRIBE
`List-Subscribe` — URL(s) / mailto to join the list (RFC 2369).
public
string
LIST_SUBSCRIBE
= 'List-Subscribe'
LIST_UNSUBSCRIBE
`List-Unsubscribe` — URL(s) / mailto to leave the list (RFC 2369).
public
string
LIST_UNSUBSCRIBE
= 'List-Unsubscribe'
LIST_UNSUBSCRIBE_POST
`List-Unsubscribe-Post` — Enables one-click unsubscribe (RFC 8058).
public
string
LIST_UNSUBSCRIBE_POST
= 'List-Unsubscribe-Post'
MESSAGE_ID
`Message-ID` — Unique identifier of this message.
public
string
MESSAGE_ID
= 'Message-ID'
MIME_VERSION
`MIME-Version` — Declares the MIME version used (always `1.0`).
public
string
MIME_VERSION
= 'MIME-Version'
ORGANIZATION
`Organization` — Organization of the sender.
public
string
ORGANIZATION
= 'Organization'
ORIGINAL_MESSAGE_ID
`Original-Message-ID` — Message-ID of the message a notification refers to.
public
string
ORIGINAL_MESSAGE_ID
= 'Original-Message-ID'
PRECEDENCE
`Precedence` — Legacy hint (`bulk` / `list` / `junk`) used to suppress auto-replies.
public
string
PRECEDENCE
= 'Precedence'
PRIORITY
`Priority` — Processing priority (`urgent` / `normal` / `non-urgent`) (RFC 2156).
public
string
PRIORITY
= 'Priority'
RECEIVED
`Received` — Trace of an MTA that handled the message (may repeat).
public
string
RECEIVED
= 'Received'
RECEIVED_SPF
`Received-SPF` — Result of an SPF check performed by a receiver (RFC 7208).
public
string
RECEIVED_SPF
= 'Received-SPF'
REFERENCES
`References` — Message-ID(s) identifying the conversation thread.
public
string
REFERENCES
= 'References'
REPLY_TO
`Reply-To` — Mailbox(es) to which replies should be sent.
public
string
REPLY_TO
= 'Reply-To'
RESENT_BCC
`Resent-Bcc` — Blind carbon-copy recipient(s) of the resending.
public
string
RESENT_BCC
= 'Resent-Bcc'
RESENT_CC
`Resent-Cc` — Carbon-copy recipient(s) of the resending.
public
string
RESENT_CC
= 'Resent-Cc'
RESENT_DATE
`Resent-Date` — Date the message was resent.
public
string
RESENT_DATE
= 'Resent-Date'
RESENT_FROM
`Resent-From` — Author(s) of the resending.
public
string
RESENT_FROM
= 'Resent-From'
RESENT_MESSAGE_ID
`Resent-Message-ID` — Unique identifier of the resending.
public
string
RESENT_MESSAGE_ID
= 'Resent-Message-ID'
RESENT_SENDER
`Resent-Sender` — Agent responsible for the resending.
public
string
RESENT_SENDER
= 'Resent-Sender'
RESENT_TO
`Resent-To` — Primary recipient(s) of the resending.
public
string
RESENT_TO
= 'Resent-To'
RETURN_PATH
`Return-Path` — Reverse-path (envelope sender) recorded at final delivery.
public
string
RETURN_PATH
= 'Return-Path'
RETURN_RECEIPT_TO
`Return-Receipt-To` — Legacy, non-standard read-receipt request.
public
string
RETURN_RECEIPT_TO
= 'Return-Receipt-To'
SENDER
`Sender` — Mailbox of the agent responsible for the actual transmission.
public
string
SENDER
= 'Sender'
SENSITIVITY
`Sensitivity` — Privacy hint (`Personal` / `Private` / `Company-Confidential`) (RFC 2156).
public
string
SENSITIVITY
= 'Sensitivity'
SUBJECT
`Subject` — Topic of the message.
public
string
SUBJECT
= 'Subject'
TO
`To` — Primary recipient(s) of the message.
public
string
TO
= 'To'
X_MAILER
`X-Mailer` — Software that generated the message.
public
string
X_MAILER
= 'X-Mailer'
X_PRIORITY
`X-Priority` — Legacy numeric priority `1` (highest) to `5` (lowest).
public
string
X_PRIORITY
= 'X-Priority'
Methods
all()
Returns a copy of the header map with every key rewritten to its canonical casing (see {@see self::normalize()}).
public
static all(array<string, string> $headers) : array<string, string>
Parameters
- $headers : array<string, string>
-
The source header map.
Return values
array<string, string> —A new map with canonical header names.
canRepeat()
Whether a header may legitimately appear more than once in a message (trace fields, resent blocks, signatures, free-form comments…).
public
static canRepeat(string $name) : bool
Parameters
- $name : string
-
The header name (case-insensitive).
Return values
bool —True if multiple occurrences are allowed.
get()
Returns the value of a header, looked up case-insensitively.
public
static get(array<string, string> $headers, string $name[, string|null $default = null ]) : string|null
Parameters
- $headers : array<string, string>
-
The header map to inspect.
- $name : string
-
The header name to look for.
- $default : string|null = null
-
Value returned when the header is absent.
Return values
string|null —The header value, or $default.
has()
Checks whether a header is present, case-insensitively.
public
static has(array<string, string> $headers, string $name) : bool
Parameters
- $headers : array<string, string>
-
The header map to inspect.
- $name : string
-
The header name to look for.
Return values
bool —True if a matching header exists.
normalize()
Returns the canonical wire-format casing of a header name.
public
static normalize(string $name) : string
Known headers are mapped to their declared constant value (e.g.
message-id → Message-ID, mime-version → MIME-Version);
unknown names fall back to Train-Case (x-foo-bar → X-Foo-Bar).
Parameters
- $name : string
-
The header name in any casing.
Return values
string —The canonical header name.
remove()
Returns a copy of the map with every case-insensitive occurrence of a header removed.
public
static remove(array<string, string> $headers, string $name) : array<string, string>
Parameters
- $headers : array<string, string>
-
The source header map.
- $name : string
-
The header name to remove.
Return values
array<string, string> —A new map without the header.
set()
Returns a copy of the map with the header set to a single value, using canonical casing and replacing any previous case-insensitive occurrence.
public
static set(array<string, string> $headers, string $name, string $value) : array<string, string>
No validation is performed: custom (X-*) headers are intentionally
allowed, unlike HttpHeader::send().
Parameters
- $headers : array<string, string>
-
The source header map.
- $name : string
-
The header name to set.
- $value : string
-
The header value.
Return values
array<string, string> —A new map with the header set.