public function testMailHeaderFolding76Char() { $mail = new ezcMail(); $mail->from = new ezcMailAddress('*****@*****.**', 'John Doe'); $mail->addTo(new ezcMailAddress('*****@*****.**', 'John Doe')); $mail->body = new ezcMailText('Text'); // test some subject sizes for ($i = 1; $i < 300; $i++) { $mail->subject = str_repeat('1', $i); $source = $mail->generate(); preg_match('/Subject:\\s[0-9]+/', $source, $matches); $this->assertEquals(1, count($matches), "Subject is folded incorrectly for length {$i}."); } }
public function testMail4() { $mail = new ezcMail(); $mail->from = new ezcMailAddress('*****@*****.**', 'Norwegian characters: æøå', 'iso-8859-1'); $mail->addTo(new ezcMailAddress('*****@*****.**', 'More norwegian characters: æøå', 'iso-8859-1')); $mail->subject = 'Oslo ligger sør i Norge og har vært landets hovedstad i over 600 år.'; $mail->subjectCharset = 'iso-8859-1'; $mail->body = new ezcMailText('Oslo be grunnlagt rundt 1048 av Harald Hardråde.', 'iso-8859-1'); $transport = new ezcMailMtaTransport(); // $transport->send( $mail ); }
/** * Test for issue #16154: Bcc headers are not stripped when using SMTP */ public function testStripBccHeader() { $options = new ezcMailOptions(); $options->stripBccHeader = true; $mail = new ezcMail($options); $mail->from = new ezcMailAddress("*****@*****.**", "No Spam 1"); $mail->addTo(new ezcMailAddress("*****@*****.**", "No Spam 2")); $mail->addBcc(new ezcMailAddress("*****@*****.**", "No Spam 3")); $mail->subject = __FUNCTION__; $source = $mail->generate(); // Assert that the mail source doesn't contain the Bcc header $this->assertEquals(false, strpos($source, "Bcc: ")); }
public function testReplyToReply() { $mail = new ezcMail(); $mail->addTo(new ezcMailAddress('*****@*****.**', 'Fræderik Hølljen', 'ISO-8859-1')); $address = new ezcMailAddress('*****@*****.**', 'Reply Går', 'ISO-8859-1'); $mail->setHeader('Reply-To', ezcMailTools::composeEmailAddress($address)); // $mail->setHeader( 'Reply-To', '*****@*****.**' ); $reply = ezcMailTools::replyToMail($mail, new ezcMailAddress('*****@*****.**', 'Reply Går', 'ISO-8859-1')); $this->assertEquals($reply->to, array(new ezcMailAddress('*****@*****.**', "Reply GÃ¥r", 'utf-8'))); }
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])); } }
<?php require_once 'tutorial_autoload.php'; // Create a new mail object $mail = new ezcMail(); // Specify the "from" mail address $mail->from = new ezcMailAddress('*****@*****.**', 'Norwegian characters: æøå', 'iso-8859-1'); // Add one "to" mail address (multiple can be added) $mail->addTo(new ezcMailAddress('*****@*****.**', 'More norwegian characters: æøå', 'iso-8859-1')); // Specify the subject of the mail $mail->subject = 'Oslo ligger sør i Norge og har vært landets hovedstad i over 600 år.'; // Specify the charset of the subject $mail->subjectCharset = 'iso-8859-1'; // Add a header with the default charset (us-ascii) $mail->setHeader('X-Related-City', 'Moscow'); // Add a header with a custom charset (iso-8859-5) $mail->setHeader('X-Related-Movie', 'James Bond - Å leve og la dø', 'iso-8859-1'); // Specify the body as a text part, also specifying it's charset $mail->body = new ezcMailText('Oslo be grunnlagt rundt 1048 av Harald Hardråde.', 'iso-8859-1'); // Create a new MTA transport object $transport = new ezcMailMtaTransport(); // Use the MTA transport to send the created mail object $transport->send($mail);
public function testTagInHeadersAndBody() { $imap = new ezcMailImapTransport(self::$server, self::$port); $imap->authenticate(self::$user, self::$password); $imap->createMailbox("Guybrush"); $mail = new ezcMail(); $mail->from = new ezcMailAddress('*****@*****.**', 'From'); $mail->addTo(new ezcMailAddress('*****@*****.**', 'To')); $mail->subject = "A0000 A0001 A0002 A0003 A0004 A0005 A0006 A0007"; $mail->body = new ezcMailText("A0000\nA0001\nA0002\nA0003\nA0004\nA0005\nA0006\nA0007"); $data = $mail->generate(); $imap->append("Guybrush", $data); $imap->append("Guybrush", $data, array('Answered')); $imap->selectMailbox("Guybrush"); $set = $imap->fetchAll(); $parser = new ezcMailParser(); $mail = $parser->parseMail($set); $mail = $mail[0]; $imap->selectMailbox("Inbox"); $imap->deleteMailbox("Guybrush"); $this->assertEquals('A0000 A0001 A0002 A0003 A0004 A0005 A0006 A0007', $mail->subject); }
<?php require_once 'tutorial_autoload.php'; // Create a new mail object $mail = new ezcMail(); // Specify the "from" mail address $mail->from = new ezcMailAddress('*****@*****.**', 'Largo LaGrande'); // Add one "to" mail address (multiple can be added) $mail->addTo(new ezcMailAddress('*****@*****.**', 'Wally B. Feed')); // Specify the subject of the mail $mail->subject = "This is the subject of the mail with a mail digest."; // Create a text part to be added to the mail $textPart = new ezcMailText("This is the body of the mail with a mail digest."); // Specify the body of the mail as a multipart-mixed of the text part and a RFC822 digest object // where $digest is an ezcMail object // and RFC822Digest is the class from the previous example $mail->body = new ezcMailMultipartMixed($textPart, new RFC822Digest($digest)); // Create a new MTA transport object $transport = new ezcMailMtaTransport(); // Use the MTA transport to send the created mail object $transport->send($mail);
public function testContentDispositionLongHeader() { $mail = new ezcMail(); $mail->from = new ezcMailAddress('*****@*****.**'); $mail->subject = "яверасфăîţâşåæøåöä"; $mail->addTo(new ezcMailAddress('*****@*****.**')); $file = new ezcMailFile(dirname(__FILE__) . "/parts/data/fly.jpg"); $file->contentDisposition = new ezcMailContentDispositionHeader('attachment', 'яверасфăîţâşåæøåöäabcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz.jpg'); $mail->body = new ezcMailMultipartMixed(new ezcMailText('xxx'), $file); $msg = $mail->generate(); $set = new ezcMailVariableSet($msg); $parser = new ezcMailParser(); $mail = $parser->parseMail($set); $parts = $mail[0]->fetchParts(); // for issue #13038, displayFileName was added to contentDisposition $file->contentDisposition->displayFileName = 'яверасфăîţâşåæøåöäabcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz.jpg'; $this->assertEquals($file->contentDisposition, $parts[1]->contentDisposition); }
<?php require_once 'tutorial_autoload.php'; // Create a new mail object $mail = new ezcMail(); // Specify the "from" mail address $mail->from = new ezcMailAddress('*****@*****.**', 'Bernard Bernoulli'); // Add one "to" mail address (multiple can be added) $mail->addTo(new ezcMailAddress('*****@*****.**', 'Wendy')); // Specify the subject of the mail $mail->subject = "This is the subject of the example mail"; // Create a text part to be added to the mail $textPart = new ezcMailText("This is the body of the example mail."); // Create a file attachment to be added to the mail $fileAttachment = new ezcMailFile("~/myfile.jpg"); // Specify the body of the mail as a multipart-mixed of the text part and the file attachment $mail->body = new ezcMailMultipartMixed($textPart, $fileAttachment); // Create a new MTA transport object $transport = new ezcMailMtaTransport(); // Use the MTA transport to send the created mail object $transport->send($mail);
<?php require_once '/home/dotxp/dev/PHP/zetacomponents/trunk/Base/src/ezc_bootstrap.php'; $imapOptions = new ezcMailImapTransportOptions(); $imapOptions->ssl = true; $imap = new ezcMailImapTransport('example.com', 993, $imapOptions); $imap->authenticate('*****@*****.**', 'foo23bar'); $imap->selectMailbox('Inbox'); $mailSet = $imap->fetchAll(); $parser = new ezcMailParser(); $retMails = $parser->parseMail($mailSet); $mail = new ezcMail(); $mail->from = new ezcMailAddress('*****@*****.**'); $mail->addTo(new ezcMailAddress('*****@*****.**', 'Any Body')); $mail->subject = 'Daily digest'; $digest = new ezcMailMultipartDigest(); foreach ($retMails as $retMail) { $digest->appendPart(new ezcMailRfc822Digest($retMail)); } $mail->body = $digest; $transport = new ezcMailMtaTransport(); $transport->send($mail);
<?php require_once 'tutorial_autoload.php'; // Create a new mail object $mail = new ezcMail(); // Specify the "from" mail address $mail->from = new ezcMailAddress('*****@*****.**', 'Boston Low'); // Add one "to" mail address (multiple can be added) $mail->addTo(new ezcMailAddress('*****@*****.**', 'Maggie Robbins')); // Specify the subject of the mail $mail->subject = "This is the subject of the example mail"; // Specify the body text of the mail as a ezcMailText object $mail->body = new ezcMailText("This is the body of the example mail."); // Create a new MTA transport object $transport = new ezcMailMtaTransport(); // Use the MTA transport to send the created mail object $transport->send($mail);
$mailAddresses = array(new ezcMailAddress('*****@*****.**', 'Jøhn Doe', 'ISO-8859-1'), new ezcMailAddress('*****@*****.**', 'Jane Doe')); $addresses = '=?ISO-8859-1?B?SsO4aG4gRG9l?= <*****@*****.**>, Jane Doe <*****@*****.**'; // Convert ezcMailAddress to string representation var_dump(ezcMailTools::composeEmailAddress($mailAddresses[0])); var_dump(ezcMailTools::composeEmailAddresses($mailAddresses)); // Convert string to ezcMailAddress var_dump(ezcMailTools::parseEmailAddress($addresses)); var_dump(ezcMailTools::parseEmailAddresses($addresses)); // Validate an email address (with a regular expression, without checking for MX records) $isValid = ezcMailTools::validateEmailAddress('*****@*****.**'); // Validate an email address with MX records check. // MX record checking does not work on Windows due to the lack of getmxrr() // and checkdnsrr() PHP functions. The ezcBaseFunctionalityNotSupportedException // is thrown in this case. // set this to your mail server, it is used in a // 'HELO SMTP' command to validate against MX records ezcMailTools::$mxValidateServer = 'your.mail.server'; // set this to a mail address such as '*****@*****.**', it is used in a // 'MAIL FROM' SMTP command to validate against MX records ezcMailTools::$mxValidateAddress = '*****@*****.**'; $isValid = ezcMailTools::validateEmailAddress('*****@*****.**', true); // Create a new mail object $mail = new ezcMail(); $mail->from = $mailAddresses[1]; $mail->addTo($mailAddresses[0]); $mail->subject = "Top secret"; // Use the lineBreak() method $mail->body = new ezcMailText("Confidential" . ezcMailTools::lineBreak() . "DO NOT READ"); $mail->generate(); // Create a reply message to the previous mail object $reply = ezcMailTools::replyToMail($mail, new ezcMailAddress('*****@*****.**', 'Reply Guy'));