Path Headers

Path headers are like very-restricted mailbox headers. They contain a single email address with no associated name. The Return-Path header of a message is a path header.

You add a new path header to a HeaderSet by calling the HeaderSet's addPathHeader() method.

<?php

$message = Swift_Message::newInstance();

$headers = $message->getHeaders();

$headers->addPathHeader('Your-Header-Name', 'person@example.org');

Changing the value of an existing path header is done by calling its setAddress() method.

<?php

$return = $message->getHeaders()->getHeader('Return-Path');

$return->setAddress('my-address@example.org');

When output via toString(), a path header produces something like the following:

<?php

$return = $message->getHeaders()->getHeader('Return-Path');

$return->setAddress('person@example.org');

echo $return->toString();

/*

Return-Path: <person@example.org>

*/

NOTE: Documentation for version 3 is in the wiki.