function testParseEmailString() { $emails = array('*****@*****.**' => '*****@*****.**', '<*****@*****.**>' => '*****@*****.**', 'Baz <*****@*****.**>' => '*****@*****.**'); foreach ($emails as $string => $email) { $results = PostmarkMailer::parse_email_addresses($string); $this->assertEquals(1, count($results)); $this->assertEquals($email, $results[0]); } $complex = array('foo@bar.com, bar@foo.com' => array('*****@*****.**', '*****@*****.**'), 'Baz <*****@*****.**>, bar@foo.com' => array('*****@*****.**', '*****@*****.**')); foreach ($complex as $string => $emails) { $results = PostmarkMailer::parse_email_addresses($string); $this->assertEquals(2, count($results)); $this->assertEquals($emails, $results); } }
public static function ReplyToMessageID($reply_to_message) { self::$reply_to_message = $reply_to_message; }
public function postmessage($data, $form) { $signature = PostmarkSignature::get()->byID($data['FromID']); PostmarkMailer::RecordEmails(true); PostmarkMailer::ReplyToMessageID($data['InReplyToID']); $clients = PostmarkHelper::client_list()->filter('ID', $data['ToMemberID']); foreach ($clients as $client) { $email = new Email($signature->Email, $client->Email, $data['Subject'], PostmarkHelper::MergeEmailText($data['Body'], $client)); for ($i = 1; $i <= 5; $i += 1) { $strKey = 'Attachment_' . $i; if (isset($_FILES[$strKey]) && $_FILES[$strKey]['tmp_name']) { $contents = file_get_contents($_FILES[$strKey]['tmp_name']); if (strlen($contents)) { $email->attachFileFromString($contents, $_FILES[$strKey]['name']); } } } $this->extend('updatePostmessage', $email, $data); $email->setTemplate('NewsletterTemplate'); $email->send(); } PostmarkMailer::RecordEmails(false); PostmarkMailer::ReplyToMessageID(0); }