Skip to content
Permalink
Browse files

Add getOriginalSubject to Email to get the subject without encoding

  • Loading branch information...
Marlinc committed Mar 18, 2016
1 parent c694b47 commit 94b864b40f9c38668224e8bec317843229a539c3
Showing with 13 additions and 4 deletions.
  1. +12 −3 src/Mailer/Email.php
  2. +1 −1 tests/TestCase/Mailer/EmailTest.php
@@ -695,18 +695,27 @@ protected function _addEmail($varName, $email, $name)
* Get/Set Subject.
*
* @param string|null $subject Subject string.
* @param bool $decode Whether to decode the subject.
* @return string|$this
*/
public function subject($subject = null, $decode = false)
public function subject($subject = null)
{
if ($subject === null) {
return ($decode) ? $this->_decode($this->_subject) : $this->_subject;
return $this->_subject;
}
$this->_subject = $this->_encode((string)$subject);
return $this;
}
/**
* Get original subject without encoding
*
* @return string Original subject
*/
public function getOriginalSubject()
{
return $this->_decode($this->_subject);
}
/**
* Sets headers for the message
*
@@ -577,7 +577,7 @@ public function testSubject()
$this->CakeEmail->subject($input);
$expected = '=?UTF-8?B?2YfYsNmHINix2LPYp9mE2Kkg2KjYudmG2YjYp9mGINi32YjZitmEINmF2LE=?=' . "\r\n" . ' =?UTF-8?B?2LPZhCDZhNmE2YXYs9iq2YTZhQ==?=';
$this->assertSame($expected, $this->CakeEmail->subject());
$this->assertSame($input, $this->CakeEmail->subject(null, true));
$this->assertSame($input, $this->CakeEmail->getOriginalSubject());
}
/**

0 comments on commit 94b864b

Please sign in to comment.
You can’t perform that action at this time.