Package Home

Zend Framework 2 Documentation (Manual)

PHK Home

File: /modules/zend.mail.additional-headers.html

Size:9871
Storage flags:no_autoload,compress/gzip (32%)

Additional Headers — Zend Framework 2 2.4.2 documentation

Additional HeadersΒΆ

Zend\Mail\Message provides several methods to set additional Mail Headers:

  • setReplyTo($email, $name=null): sets the Reply-To: header.
  • setDate($date = null): sets the Date: header. This method uses current time stamp by default. Or You can pass time stamp, date string or DateTime instance to this method.
  • setMessageId($id = true): sets the Message-Id: header. This method can generate message ID automatically by default. Or You can pass your message ID string to this method. This method call createMessageId() internally.

Note

Return-Path

If you set Return-Path on your mail, see Configuring sendmail transport. Unfortunately, setReturnPath($email) method does not perform this purpose.

Furthermore, arbitrary mail headers can be set by using the addHeader() method. It requires two parameters containing the name and the value of the header field. A third optional parameter determines if the header should have only one or multiple values:

Adding E-Mail Message Headers

1
2
3
4
$mail = new Zend\Mail\Message();
$mail->addHeader('X-MailGenerator', 'MyCoolApplication');
$mail->addHeader('X-greetingsTo', 'Mom', true); // multiple values
$mail->addHeader('X-greetingsTo', 'Dad', true);

This Page

Note: You need to stay logged into your GitHub account to contribute to the documentation.

Edit this document

Edit this document

The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.

  1. Login with your GitHub account.
  2. Go to Additional Headers on GitHub.
  3. Edit file contents using GitHub's text editor in your web browser
  4. Fill in the Commit message text box at the end of the page telling why you did the changes. Press Propose file change button next to it when done.
  5. On Send a pull request page you don't need to fill in text anymore. Just press Send pull request button.
  6. Your changes are now queued for review under project's Pull requests tab on GitHub.

For more information about the PHK package format: http://phk.tekwire.net