Adding new Headers
New headers can be added to the HeaderSet by using one of the provided add..Header() methods.
To add a header to a MIME entity (such as the message):
- Get the HeaderSet from the entity by via its getHeaders() method.
- Add the header to the HeaderSet by calling one of the add..Header() methods described in Header Types.
The added header will appear in the message when it is sent.
//Adding a custom header to a message
$message = Swift_Message::newInstance();
$headers = $message->getHeaders();
$headers->addTextHeader('X-Mine', 'something here');
//Adding a custom header to an attachment
$attachment = Swift_Attachment::fromPath('/path/to/doc.pdf');
$attachment->getHeaders()->addDateHeader('X-Created-Time', time());
Parent topic: Header Operations
Next topic: Retrieving Headers