Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Restore mail message from string #2333

Merged
merged 3 commits into from

3 participants

@Xerkus

Message restored from string to Mail\Message with raw body.
Decoding to Mime\Part will be added in other PR when i figure out how to do that properly.

tests/ZendTest/Mail/MessageTest.php
@@ -647,4 +647,16 @@ public function testDefaultDateHeaderEncodingIsAlwaysAscii()
$test = substr($test, 0, 16);
$this->assertEquals($date, $test);
}
+
+ public function testRestoreFromSerializedString()
+ {
+ $this->message->addTo('zf-devteam@zend.com', 'ZF DevTeam');
@Freeaqingme Collaborator

Please replace the email addresses so that they end with @example.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Freeaqingme Freeaqingme commented on the diff
library/Zend/Mail/Message.php
@@ -535,4 +535,24 @@ public function toString()
. Headers::EOL
. $this->getBodyText();
}
+
+ /**
+ * Set from serialized string
+ *
+ * @param string $rawMessage
+ * @return Message
+ */
+ public static function fromString($rawMessage)
+ {
+ $message = new static();
+ $headers = null;
+ $content = null;
+ Mime\Decode::splitMessage($rawMessage, $headers, $content);
+ if ($headers->has('mime-version')) {
+ // @todo restore body to mime\message
@Freeaqingme Collaborator

Maybe implement this, or throw an exception here (and add appropriate unit test)?

@Xerkus
Xerkus added a note

Exception is not required here as message is valid with raw body. Converting it to Mime\Message might be needed for further message manipulations. End user should check if body is string or object anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Freeaqingme
Collaborator

@Xerkus can you please spcify the use case you had in mind while developing this method?

library/Zend/Mail/Message.php
@@ -535,4 +535,24 @@ public function toString()
. Headers::EOL
. $this->getBodyText();
}
+
+ /**
+ * Set from serialized string
@Freeaqingme Collaborator

Is this accurate? I would suggest something along the lines of 'Instantiate from plain mime document'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Xerkus

@Freeaqingme My use case is simple: store message as string to retrieve and send it later from separate process.

@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney [#2333] Add todo annotation
- Added @todo annotation so it's discoverable via API docs
eb9850e
@weierophinney

Merged to master.

@weierophinney weierophinney merged commit bedd30b into zendframework:master
@froschdesign froschdesign referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@froschdesign froschdesign referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@froschdesign froschdesign referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@froschdesign froschdesign referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@froschdesign froschdesign referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@robertboloc robertboloc referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@basz basz referenced this pull request from a commit
@weierophinney weierophinney [#2333] Add todo annotation
- Added @todo annotation so it's discoverable via API docs
dc69012
@robertboloc robertboloc referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@robertboloc robertboloc referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@robertboloc robertboloc referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@robertboloc robertboloc referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@froschdesign froschdesign referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@AlloVince AlloVince referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@froschdesign froschdesign referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@froschdesign froschdesign referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@froschdesign froschdesign referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney [#2333] Add todo annotation
- Added @todo annotation so it's discoverable via API docs
96dd9de
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-mail
@weierophinney weierophinney [zendframework/zf2#2333] Add todo annotation
- Added @todo annotation so it's discoverable via API docs
80f1267
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 123 additions and 91 deletions.
  1. +20 −0 library/Zend/Mail/Message.php
  2. +103 −91 tests/ZendTest/Mail/MessageTest.php
View
20 library/Zend/Mail/Message.php
@@ -535,4 +535,24 @@ public function toString()
. Headers::EOL
. $this->getBodyText();
}
+
+ /**
+ * Instantiate from raw message string
+ *
+ * @param string $rawMessage
+ * @return Message
+ */
+ public static function fromString($rawMessage)
+ {
+ $message = new static();
+ $headers = null;
+ $content = null;
+ Mime\Decode::splitMessage($rawMessage, $headers, $content);
+ if ($headers->has('mime-version')) {
+ // @todo restore body to mime\message
@Freeaqingme Collaborator

Maybe implement this, or throw an exception here (and add appropriate unit test)?

@Xerkus
Xerkus added a note

Exception is not required here as message is valid with raw body. Converting it to Mime\Message might be needed for further message manipulations. End user should check if body is string or object anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ }
+ $message->setHeaders($headers);
+ $message->setBody($content);
+ return $message;
+ }
}
View
194 tests/ZendTest/Mail/MessageTest.php
@@ -56,7 +56,7 @@ public function testSetsOrigDateHeaderByDefault()
public function testAddingFromAddressMarksAsValid()
{
- $this->message->addFrom('zf-devteam@zend.com');
+ $this->message->addFrom('zf-devteam@example.com');
$this->assertTrue($this->message->isValid());
}
@@ -68,14 +68,14 @@ public function testHeadersMethodReturnsHeadersObject()
public function testToMethodReturnsAddressListObject()
{
- $this->message->addTo('zf-devteam@zend.com');
+ $this->message->addTo('zf-devteam@example.com');
$to = $this->message->getTo();
$this->assertInstanceOf('Zend\Mail\AddressList', $to);
}
public function testToAddressListLivesInHeaders()
{
- $this->message->addTo('zf-devteam@zend.com');
+ $this->message->addTo('zf-devteam@example.com');
$to = $this->message->getTo();
$headers = $this->message->getHeaders();
$this->assertInstanceOf('Zend\Mail\Headers', $headers);
@@ -86,14 +86,14 @@ public function testToAddressListLivesInHeaders()
public function testFromMethodReturnsAddressListObject()
{
- $this->message->addFrom('zf-devteam@zend.com');
+ $this->message->addFrom('zf-devteam@example.com');
$from = $this->message->getFrom();
$this->assertInstanceOf('Zend\Mail\AddressList', $from);
}
public function testFromAddressListLivesInHeaders()
{
- $this->message->addFrom('zf-devteam@zend.com');
+ $this->message->addFrom('zf-devteam@example.com');
$from = $this->message->getFrom();
$headers = $this->message->getHeaders();
$this->assertInstanceOf('Zend\Mail\Headers', $headers);
@@ -104,14 +104,14 @@ public function testFromAddressListLivesInHeaders()
public function testCcMethodReturnsAddressListObject()
{
- $this->message->addCc('zf-devteam@zend.com');
+ $this->message->addCc('zf-devteam@example.com');
$cc = $this->message->getCc();
$this->assertInstanceOf('Zend\Mail\AddressList', $cc);
}
public function testCcAddressListLivesInHeaders()
{
- $this->message->addCc('zf-devteam@zend.com');
+ $this->message->addCc('zf-devteam@example.com');
$cc = $this->message->getCc();
$headers = $this->message->getHeaders();
$this->assertInstanceOf('Zend\Mail\Headers', $headers);
@@ -122,14 +122,14 @@ public function testCcAddressListLivesInHeaders()
public function testBccMethodReturnsAddressListObject()
{
- $this->message->addBcc('zf-devteam@zend.com');
+ $this->message->addBcc('zf-devteam@example.com');
$bcc = $this->message->getBcc();
$this->assertInstanceOf('Zend\Mail\AddressList', $bcc);
}
public function testBccAddressListLivesInHeaders()
{
- $this->message->addBcc('zf-devteam@zend.com');
+ $this->message->addBcc('zf-devteam@example.com');
$bcc = $this->message->getBcc();
$headers = $this->message->getHeaders();
$this->assertInstanceOf('Zend\Mail\Headers', $headers);
@@ -140,14 +140,14 @@ public function testBccAddressListLivesInHeaders()
public function testReplyToMethodReturnsAddressListObject()
{
- $this->message->addReplyTo('zf-devteam@zend.com');
+ $this->message->addReplyTo('zf-devteam@example.com');
$replyTo = $this->message->getReplyTo();
$this->assertInstanceOf('Zend\Mail\AddressList', $replyTo);
}
public function testReplyToAddressListLivesInHeaders()
{
- $this->message->addReplyTo('zf-devteam@zend.com');
+ $this->message->addReplyTo('zf-devteam@example.com');
$replyTo = $this->message->getReplyTo();
$headers = $this->message->getHeaders();
$this->assertInstanceOf('Zend\Mail\Headers', $headers);
@@ -163,14 +163,14 @@ public function testSenderIsNullByDefault()
public function testSettingSenderCreatesAddressObject()
{
- $this->message->setSender('zf-devteam@zend.com');
+ $this->message->setSender('zf-devteam@example.com');
$sender = $this->message->getSender();
$this->assertInstanceOf('Zend\Mail\Address', $sender);
}
public function testCanSpecifyNameWhenSettingSender()
{
- $this->message->setSender('zf-devteam@zend.com', 'ZF DevTeam');
+ $this->message->setSender('zf-devteam@example.com', 'ZF DevTeam');
$sender = $this->message->getSender();
$this->assertInstanceOf('Zend\Mail\Address', $sender);
$this->assertEquals('ZF DevTeam', $sender->getName());
@@ -178,7 +178,7 @@ public function testCanSpecifyNameWhenSettingSender()
public function testCanProvideAddressObjectWhenSettingSender()
{
- $sender = new Address('zf-devteam@zend.com');
+ $sender = new Address('zf-devteam@example.com');
$this->message->setSender($sender);
$test = $this->message->getSender();
$this->assertSame($sender, $test);
@@ -188,24 +188,24 @@ public function testSenderAccessorsProxyToSenderHeader()
{
$header = new Header\Sender();
$this->message->getHeaders()->addHeader($header);
- $address = new Address('zf-devteam@zend.com', 'ZF DevTeam');
+ $address = new Address('zf-devteam@example.com', 'ZF DevTeam');
$this->message->setSender($address);
$this->assertSame($address, $header->getAddress());
}
public function testCanAddFromAddressUsingName()
{
- $this->message->addFrom('zf-devteam@zend.com', 'ZF DevTeam');
+ $this->message->addFrom('zf-devteam@example.com', 'ZF DevTeam');
$addresses = $this->message->getFrom();
$this->assertEquals(1, count($addresses));
$address = $addresses->current();
- $this->assertEquals('zf-devteam@zend.com', $address->getEmail());
+ $this->assertEquals('zf-devteam@example.com', $address->getEmail());
$this->assertEquals('ZF DevTeam', $address->getName());
}
public function testCanAddFromAddressUsingAddressObject()
{
- $address = new Address('zf-devteam@zend.com', 'ZF DevTeam');
+ $address = new Address('zf-devteam@example.com', 'ZF DevTeam');
$this->message->addFrom($address);
$addresses = $this->message->getFrom();
@@ -217,59 +217,59 @@ public function testCanAddFromAddressUsingAddressObject()
public function testCanAddManyFromAddressesUsingArray()
{
$addresses = array(
- 'zf-devteam@zend.com',
- 'zf-contributors@lists.zend.com' => 'ZF Contributors List',
- new Address('fw-announce@lists.zend.com', 'ZF Announce List'),
+ 'zf-devteam@example.com',
+ 'zf-contributors@example.com' => 'ZF Contributors List',
+ new Address('fw-announce@example.com', 'ZF Announce List'),
);
$this->message->addFrom($addresses);
$from = $this->message->getFrom();
$this->assertEquals(3, count($from));
- $this->assertTrue($from->has('zf-devteam@zend.com'));
- $this->assertTrue($from->has('zf-contributors@lists.zend.com'));
- $this->assertTrue($from->has('fw-announce@lists.zend.com'));
+ $this->assertTrue($from->has('zf-devteam@example.com'));
+ $this->assertTrue($from->has('zf-contributors@example.com'));
+ $this->assertTrue($from->has('fw-announce@example.com'));
}
public function testCanAddManyFromAddressesUsingAddressListObject()
{
$list = new AddressList();
- $list->add('zf-devteam@zend.com');
+ $list->add('zf-devteam@example.com');
- $this->message->addFrom('fw-announce@lists.zend.com');
+ $this->message->addFrom('fw-announce@example.com');
$this->message->addFrom($list);
$from = $this->message->getFrom();
$this->assertEquals(2, count($from));
- $this->assertTrue($from->has('fw-announce@lists.zend.com'));
- $this->assertTrue($from->has('zf-devteam@zend.com'));
+ $this->assertTrue($from->has('fw-announce@example.com'));
+ $this->assertTrue($from->has('zf-devteam@example.com'));
}
public function testCanSetFromListFromAddressList()
{
$list = new AddressList();
- $list->add('zf-devteam@zend.com');
+ $list->add('zf-devteam@example.com');
- $this->message->addFrom('fw-announce@lists.zend.com');
+ $this->message->addFrom('fw-announce@example.com');
$this->message->setFrom($list);
$from = $this->message->getFrom();
$this->assertEquals(1, count($from));
- $this->assertFalse($from->has('fw-announce@lists.zend.com'));
- $this->assertTrue($from->has('zf-devteam@zend.com'));
+ $this->assertFalse($from->has('fw-announce@example.com'));
+ $this->assertTrue($from->has('zf-devteam@example.com'));
}
public function testCanAddCcAddressUsingName()
{
- $this->message->addCc('zf-devteam@zend.com', 'ZF DevTeam');
+ $this->message->addCc('zf-devteam@example.com', 'ZF DevTeam');
$addresses = $this->message->getCc();
$this->assertEquals(1, count($addresses));
$address = $addresses->current();
- $this->assertEquals('zf-devteam@zend.com', $address->getEmail());
+ $this->assertEquals('zf-devteam@example.com', $address->getEmail());
$this->assertEquals('ZF DevTeam', $address->getName());
}
public function testCanAddCcAddressUsingAddressObject()
{
- $address = new Address('zf-devteam@zend.com', 'ZF DevTeam');
+ $address = new Address('zf-devteam@example.com', 'ZF DevTeam');
$this->message->addCc($address);
$addresses = $this->message->getCc();
@@ -281,59 +281,59 @@ public function testCanAddCcAddressUsingAddressObject()
public function testCanAddManyCcAddressesUsingArray()
{
$addresses = array(
- 'zf-devteam@zend.com',
- 'zf-contributors@lists.zend.com' => 'ZF Contributors List',
- new Address('fw-announce@lists.zend.com', 'ZF Announce List'),
+ 'zf-devteam@example.com',
+ 'zf-contributors@example.com' => 'ZF Contributors List',
+ new Address('fw-announce@example.com', 'ZF Announce List'),
);
$this->message->addCc($addresses);
$cc = $this->message->getCc();
$this->assertEquals(3, count($cc));
- $this->assertTrue($cc->has('zf-devteam@zend.com'));
- $this->assertTrue($cc->has('zf-contributors@lists.zend.com'));
- $this->assertTrue($cc->has('fw-announce@lists.zend.com'));
+ $this->assertTrue($cc->has('zf-devteam@example.com'));
+ $this->assertTrue($cc->has('zf-contributors@example.com'));
+ $this->assertTrue($cc->has('fw-announce@example.com'));
}
public function testCanAddManyCcAddressesUsingAddressListObject()
{
$list = new AddressList();
- $list->add('zf-devteam@zend.com');
+ $list->add('zf-devteam@example.com');
- $this->message->addCc('fw-announce@lists.zend.com');
+ $this->message->addCc('fw-announce@example.com');
$this->message->addCc($list);
$cc = $this->message->getCc();
$this->assertEquals(2, count($cc));
- $this->assertTrue($cc->has('fw-announce@lists.zend.com'));
- $this->assertTrue($cc->has('zf-devteam@zend.com'));
+ $this->assertTrue($cc->has('fw-announce@example.com'));
+ $this->assertTrue($cc->has('zf-devteam@example.com'));
}
public function testCanSetCcListFromAddressList()
{
$list = new AddressList();
- $list->add('zf-devteam@zend.com');
+ $list->add('zf-devteam@example.com');
- $this->message->addCc('fw-announce@lists.zend.com');
+ $this->message->addCc('fw-announce@example.com');
$this->message->setCc($list);
$cc = $this->message->getCc();
$this->assertEquals(1, count($cc));
- $this->assertFalse($cc->has('fw-announce@lists.zend.com'));
- $this->assertTrue($cc->has('zf-devteam@zend.com'));
+ $this->assertFalse($cc->has('fw-announce@example.com'));
+ $this->assertTrue($cc->has('zf-devteam@example.com'));
}
public function testCanAddBccAddressUsingName()
{
- $this->message->addBcc('zf-devteam@zend.com', 'ZF DevTeam');
+ $this->message->addBcc('zf-devteam@example.com', 'ZF DevTeam');
$addresses = $this->message->getBcc();
$this->assertEquals(1, count($addresses));
$address = $addresses->current();
- $this->assertEquals('zf-devteam@zend.com', $address->getEmail());
+ $this->assertEquals('zf-devteam@example.com', $address->getEmail());
$this->assertEquals('ZF DevTeam', $address->getName());
}
public function testCanAddBccAddressUsingAddressObject()
{
- $address = new Address('zf-devteam@zend.com', 'ZF DevTeam');
+ $address = new Address('zf-devteam@example.com', 'ZF DevTeam');
$this->message->addBcc($address);
$addresses = $this->message->getBcc();
@@ -345,59 +345,59 @@ public function testCanAddBccAddressUsingAddressObject()
public function testCanAddManyBccAddressesUsingArray()
{
$addresses = array(
- 'zf-devteam@zend.com',
- 'zf-contributors@lists.zend.com' => 'ZF Contributors List',
- new Address('fw-announce@lists.zend.com', 'ZF Announce List'),
+ 'zf-devteam@example.com',
+ 'zf-contributors@example.com' => 'ZF Contributors List',
+ new Address('fw-announce@example.com', 'ZF Announce List'),
);
$this->message->addBcc($addresses);
$bcc = $this->message->getBcc();
$this->assertEquals(3, count($bcc));
- $this->assertTrue($bcc->has('zf-devteam@zend.com'));
- $this->assertTrue($bcc->has('zf-contributors@lists.zend.com'));
- $this->assertTrue($bcc->has('fw-announce@lists.zend.com'));
+ $this->assertTrue($bcc->has('zf-devteam@example.com'));
+ $this->assertTrue($bcc->has('zf-contributors@example.com'));
+ $this->assertTrue($bcc->has('fw-announce@example.com'));
}
public function testCanAddManyBccAddressesUsingAddressListObject()
{
$list = new AddressList();
- $list->add('zf-devteam@zend.com');
+ $list->add('zf-devteam@example.com');
- $this->message->addBcc('fw-announce@lists.zend.com');
+ $this->message->addBcc('fw-announce@example.com');
$this->message->addBcc($list);
$bcc = $this->message->getBcc();
$this->assertEquals(2, count($bcc));
- $this->assertTrue($bcc->has('fw-announce@lists.zend.com'));
- $this->assertTrue($bcc->has('zf-devteam@zend.com'));
+ $this->assertTrue($bcc->has('fw-announce@example.com'));
+ $this->assertTrue($bcc->has('zf-devteam@example.com'));
}
public function testCanSetBccListFromAddressList()
{
$list = new AddressList();
- $list->add('zf-devteam@zend.com');
+ $list->add('zf-devteam@example.com');
- $this->message->addBcc('fw-announce@lists.zend.com');
+ $this->message->addBcc('fw-announce@example.com');
$this->message->setBcc($list);
$bcc = $this->message->getBcc();
$this->assertEquals(1, count($bcc));
- $this->assertFalse($bcc->has('fw-announce@lists.zend.com'));
- $this->assertTrue($bcc->has('zf-devteam@zend.com'));
+ $this->assertFalse($bcc->has('fw-announce@example.com'));
+ $this->assertTrue($bcc->has('zf-devteam@example.com'));
}
public function testCanAddReplyToAddressUsingName()
{
- $this->message->addReplyTo('zf-devteam@zend.com', 'ZF DevTeam');
+ $this->message->addReplyTo('zf-devteam@example.com', 'ZF DevTeam');
$addresses = $this->message->getReplyTo();
$this->assertEquals(1, count($addresses));
$address = $addresses->current();
- $this->assertEquals('zf-devteam@zend.com', $address->getEmail());
+ $this->assertEquals('zf-devteam@example.com', $address->getEmail());
$this->assertEquals('ZF DevTeam', $address->getName());
}
public function testCanAddReplyToAddressUsingAddressObject()
{
- $address = new Address('zf-devteam@zend.com', 'ZF DevTeam');
+ $address = new Address('zf-devteam@example.com', 'ZF DevTeam');
$this->message->addReplyTo($address);
$addresses = $this->message->getReplyTo();
@@ -409,44 +409,44 @@ public function testCanAddReplyToAddressUsingAddressObject()
public function testCanAddManyReplyToAddressesUsingArray()
{
$addresses = array(
- 'zf-devteam@zend.com',
- 'zf-contributors@lists.zend.com' => 'ZF Contributors List',
- new Address('fw-announce@lists.zend.com', 'ZF Announce List'),
+ 'zf-devteam@example.com',
+ 'zf-contributors@example.com' => 'ZF Contributors List',
+ new Address('fw-announce@example.com', 'ZF Announce List'),
);
$this->message->addReplyTo($addresses);
$replyTo = $this->message->getReplyTo();
$this->assertEquals(3, count($replyTo));
- $this->assertTrue($replyTo->has('zf-devteam@zend.com'));
- $this->assertTrue($replyTo->has('zf-contributors@lists.zend.com'));
- $this->assertTrue($replyTo->has('fw-announce@lists.zend.com'));
+ $this->assertTrue($replyTo->has('zf-devteam@example.com'));
+ $this->assertTrue($replyTo->has('zf-contributors@example.com'));
+ $this->assertTrue($replyTo->has('fw-announce@example.com'));
}
public function testCanAddManyReplyToAddressesUsingAddressListObject()
{
$list = new AddressList();
- $list->add('zf-devteam@zend.com');
+ $list->add('zf-devteam@example.com');
- $this->message->addReplyTo('fw-announce@lists.zend.com');
+ $this->message->addReplyTo('fw-announce@example.com');
$this->message->addReplyTo($list);
$replyTo = $this->message->getReplyTo();
$this->assertEquals(2, count($replyTo));
- $this->assertTrue($replyTo->has('fw-announce@lists.zend.com'));
- $this->assertTrue($replyTo->has('zf-devteam@zend.com'));
+ $this->assertTrue($replyTo->has('fw-announce@example.com'));
+ $this->assertTrue($replyTo->has('zf-devteam@example.com'));
}
public function testCanSetReplyToListFromAddressList()
{
$list = new AddressList();
- $list->add('zf-devteam@zend.com');
+ $list->add('zf-devteam@example.com');
- $this->message->addReplyTo('fw-announce@lists.zend.com');
+ $this->message->addReplyTo('fw-announce@example.com');
$this->message->setReplyTo($list);
$replyTo = $this->message->getReplyTo();
$this->assertEquals(1, count($replyTo));
- $this->assertFalse($replyTo->has('fw-announce@lists.zend.com'));
- $this->assertTrue($replyTo->has('zf-devteam@zend.com'));
+ $this->assertFalse($replyTo->has('fw-announce@example.com'));
+ $this->assertTrue($replyTo->has('zf-devteam@example.com'));
}
public function testSubjectIsEmptyByDefault()
@@ -604,10 +604,10 @@ public function testEncodingIsMutable()
public function testSettingNonAsciiEncodingForcesMimeEncodingOfSomeHeaders()
{
- $this->message->addTo('zf-devteam@zend.com', 'ZF DevTeam');
- $this->message->addFrom('matthew@zend.com', "Matthew Weier O'Phinney");
- $this->message->addCc('zf-contributors@lists.zend.com', 'ZF Contributors List');
- $this->message->addBcc('zf-crteam@lists.zend.com', 'ZF CR Team');
+ $this->message->addTo('zf-devteam@example.com', 'ZF DevTeam');
+ $this->message->addFrom('matthew@example.com', "Matthew Weier O'Phinney");
+ $this->message->addCc('zf-contributors@example.com', 'ZF Contributors List');
+ $this->message->addBcc('zf-crteam@example.com', 'ZF CR Team');
$this->message->setSubject('This is a subject');
$this->message->setEncoding('UTF-8');
@@ -615,19 +615,19 @@ public function testSettingNonAsciiEncodingForcesMimeEncodingOfSomeHeaders()
$expected = '=?UTF-8?Q?ZF=20DevTeam?=';
$this->assertContains($expected, $test);
- $this->assertContains('<zf-devteam@zend.com>', $test);
+ $this->assertContains('<zf-devteam@example.com>', $test);
$expected = "=?UTF-8?Q?Matthew=20Weier=20O'Phinney?=";
$this->assertContains($expected, $test, $test);
- $this->assertContains('<matthew@zend.com>', $test);
+ $this->assertContains('<matthew@example.com>', $test);
$expected = '=?UTF-8?Q?ZF=20Contributors=20List?=';
$this->assertContains($expected, $test);
- $this->assertContains('<zf-contributors@lists.zend.com>', $test);
+ $this->assertContains('<zf-contributors@example.com>', $test);
$expected = '=?UTF-8?Q?ZF=20CR=20Team?=';
$this->assertContains($expected, $test);
- $this->assertContains('<zf-crteam@lists.zend.com>', $test);
+ $this->assertContains('<zf-crteam@example.com>', $test);
$expected = 'Subject: =?UTF-8?Q?This=20is=20a=20subject?=';
$this->assertContains($expected, $test);
@@ -647,4 +647,16 @@ public function testDefaultDateHeaderEncodingIsAlwaysAscii()
$test = substr($test, 0, 16);
$this->assertEquals($date, $test);
}
+
+ public function testRestoreFromSerializedString()
+ {
+ $this->message->addTo('zf-devteam@example.com', 'ZF DevTeam');
+ $this->message->addFrom('matthew@example.com', "Matthew Weier O'Phinney");
+ $this->message->addCc('zf-contributors@example.com', 'ZF Contributors List');
+ $this->message->setSubject('This is a subject');
+ $this->message->setBody('foo');
+ $serialized = $this->message->toString();
+ $restoredMessage = Message::fromString($serialized);
+ $this->assertEquals($serialized, $restoredMessage->toString());
+ }
}
Something went wrong with that request. Please try again.