Skip to content

Commit

Permalink
Merge pull request PHPMailer#405 from eexit/header-getter
Browse files Browse the repository at this point in the history
Add custom header getter
  • Loading branch information
Synchro committed Apr 23, 2015
2 parents 095193b + 47fd54d commit 65e6f5a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.md
@@ -1,5 +1,6 @@
# ChangeLog

* Add custom header getter
* Use `application/javascript` for .js attachments
* Improve RFC2821 compliance for timelimits, especially for end-of-data
* Add Azerbaijani translations (Thanks to @mirjalal)
Expand Down
10 changes: 10 additions & 0 deletions class.phpmailer.php
Expand Up @@ -2952,6 +2952,16 @@ public function addCustomHeader($name, $value = null)
}
}

/**
* Returns all custom headers
*
* @return array
*/
public function getCustomHeaders()
{
return $this->CustomHeader;
}

/**
* Create a message from an HTML string.
* Automatically makes modifications for inline images and backgrounds
Expand Down
27 changes: 27 additions & 0 deletions test/phpmailerTest.php
Expand Up @@ -1680,6 +1680,33 @@ public function testSmtpConnect()
'SMTP connect with options failed'
);
}

/**
* Tests the Custom header getter
*/
public function testCustomHeaderGetter()
{
$this->Mail->addCustomHeader('foo', 'bar');
$this->assertEquals(array(array('foo', 'bar')), $this->Mail->getCustomHeaders());

$this->Mail->addCustomHeader('foo', 'baz');
$this->assertEquals(array(
array('foo', 'bar'),
array('foo', 'baz')
), $this->Mail->getCustomHeaders());

$this->Mail->clearCustomHeaders();
$this->assertEmpty($this->Mail->getCustomHeaders());

$this->Mail->addCustomHeader('yux');
$this->assertEquals(array(array('yux')), $this->Mail->getCustomHeaders());

$this->Mail->addCustomHeader('Content-Type: application/json');
$this->assertEquals(array(
array('yux'),
array('Content-Type', ' application/json')
), $this->Mail->getCustomHeaders());
}
}

/**
Expand Down

0 comments on commit 65e6f5a

Please sign in to comment.