/** * Parses the header given by $line. * * @param string $line * @param ezcMailHeadersHolder $headers */ protected function parseHeader($line, ezcMailHeadersHolder $headers) { $matches = array(); preg_match_all("/^([\\w-_]*):\\s?(.*)/", $line, $matches, PREG_SET_ORDER); if (count($matches) > 0) { $this->lastParsedHeader = $matches[0][1]; $this->headerValue = trim($matches[0][2]); } else { if (isset($this->lastParsedHeader) && $this->lastParsedHeader !== null) { $this->headerValue .= $line; } } if (strlen(trim($line)) == 0) { $this->section++; $this->part->createRecipient(); return; } if ($this->section == 0) { $this->part->message[$this->lastParsedHeader] = $this->headerValue; } else { $this->part->recipients[$this->section - 1][$this->lastParsedHeader] = $this->headerValue; } }
public function testMultipartReport() { $mail = new ezcMail(); $mail->from = new ezcMailAddress('*****@*****.**', 'Frederik Holljen'); $mail->addTo(new ezcMailAddress('*****@*****.**', 'Frederik Holljen')); $mail->subject = "Report"; $mail->subjectCharset = 'iso-8859-1'; $delivery = new ezcMailDeliveryStatus(); $delivery->message["Reporting-MTA"] = "dns; www.brssolutions.com"; $lastRecipient = $delivery->createRecipient(); $delivery->recipients[$lastRecipient]["Action"] = "failed"; $mail->body = new ezcMailMultipartReport(new ezcMailText("Dette er body ßßæøååå", "iso-8859-1"), $delivery, new ezcMailText("The content initially sent")); }
public function testMultipartReportFetchParts() { $mail = new ezcMail(); $mail->from = new ezcMailAddress('*****@*****.**', 'Frederik Holljen'); $mail->addTo(new ezcMailAddress('*****@*****.**', 'Frederik Holljen')); $mail->subject = "Report"; $mail->subjectCharset = 'iso-8859-1'; $delivery = new ezcMailDeliveryStatus(); $delivery->message["Reporting-MTA"] = "dns; www.brssolutions.com"; $lastRecipient = $delivery->createRecipient(); $delivery->recipients[$lastRecipient]["Action"] = "failed"; $mail->body = new ezcMailMultipartReport(new ezcMailText("Dette er body ßßæøååå", "iso-8859-1"), $delivery, new ezcMailText("The content initially sent")); $this->assertEquals("delivery-status", $mail->body->reportType); $msg = $mail->generate(); $set = new ezcMailVariableSet($msg); $parser = new ezcMailParser(); $mail = $parser->parseMail($set); $mail = $mail[0]; $parts = $mail->fetchParts(null, true); $expected = array('ezcMailText', 'ezcMailDeliveryStatus', 'ezcMailText'); $this->assertEquals(3, count($parts)); for ($i = 0; $i < count($parts); $i++) { $this->assertEquals($expected[$i], get_class($parts[$i])); } }