本文整理汇总了PHP中ezcMailTools::parseEmailAddresses方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcMailTools::parseEmailAddresses方法的具体用法?PHP ezcMailTools::parseEmailAddresses怎么用?PHP ezcMailTools::parseEmailAddresses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezcMailTools
的用法示例。
在下文中一共展示了ezcMailTools::parseEmailAddresses方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replyToMail
/**
* Returns a new mail object that is a reply to the current object.
*
* The new mail will have the correct to, cc, bcc and reference headers set.
* It will not have any body set.
*
* By default the reply will only be sent to the sender of the original mail.
* If $type is set to REPLY_ALL, all the original recipients will be included
* in the reply.
*
* Use $subjectPrefix to set the prefix to the subject of the mail. The default
* is to prefix with 'Re: '.
*
* @param ezcMail $mail
* @param ezcMailAddress $from
* @param int $type REPLY_SENDER or REPLY_ALL
* @param string $subjectPrefix
* @param string $mailClass
* @return ezcMail
*/
public static function replyToMail(ezcMail $mail, ezcMailAddress $from, $type = self::REPLY_SENDER, $subjectPrefix = "Re: ", $mailClass = "ezcMail")
{
$reply = new $mailClass();
$reply->from = $from;
// To = Reply-To if set
if ($mail->getHeader('Reply-To') != '') {
$reply->to = ezcMailTools::parseEmailAddresses($mail->getHeader('Reply-To'));
} else {
$reply->to = array($mail->from);
}
if ($type == self::REPLY_ALL) {
// Cc = Cc + To - your own address
$cc = array();
foreach ($mail->to as $address) {
if ($address->email != $from->email) {
$cc[] = $address;
}
}
foreach ($mail->cc as $address) {
if ($address->email != $from->email) {
$cc[] = $address;
}
}
$reply->cc = $cc;
}
$reply->subject = $subjectPrefix . $mail->subject;
if ($mail->getHeader('Message-Id')) {
// In-Reply-To = Message-Id
$reply->setHeader('In-Reply-To', $mail->getHeader('Message-ID'));
// References = References . Message-Id
if ($mail->getHeader('References') != '') {
$reply->setHeader('References', $mail->getHeader('References') . ' ' . $mail->getHeader('Message-ID'));
} else {
$reply->setHeader('References', $mail->getHeader('Message-ID'));
}
} else {
$reply->setHeader('References', $mail->getHeader('References'));
}
return $reply;
}
示例2: testParseEmailAddressesLocalEncoding
public function testParseEmailAddressesLocalEncoding()
{
$add = ezcMailTools::parseEmailAddresses('Test äöää<foobar@example.com>, En Lømmel <test@example.com>', 'iso-8859-1');
$this->assertEquals('Test äöää', $add[0]->name);
$this->assertEquals('foobar@example.com', $add[0]->email);
$this->assertEquals('En Lømmel', $add[1]->name);
$this->assertEquals('test@example.com', $add[1]->email);
}
示例3: finish
/**
* Returns an ezcMail corresponding to the parsed message.
* You can specify an alternate class using the $class parameter, if you
* extended ezcMail.
*
* @param string $class Class to instanciate instead of ezcMail.
* @return ezcMail
*/
public function finish($class = "ezcMail")
{
$mail = new $class();
$mail->setHeaders($this->headers->getCaseSensitiveArray());
ezcMailPartParser::parsePartHeaders($this->headers, $mail);
// from
if (isset($this->headers['From'])) {
$mail->from = ezcMailTools::parseEmailAddress($this->headers['From']);
}
// to
if (isset($this->headers['To'])) {
$mail->to = ezcMailTools::parseEmailAddresses($this->headers['To']);
}
// cc
if (isset($this->headers['Cc'])) {
$mail->cc = ezcMailTools::parseEmailAddresses($this->headers['Cc']);
}
// bcc
if (isset($this->headers['Bcc'])) {
$mail->bcc = ezcMailTools::parseEmailAddresses($this->headers['Bcc']);
}
// subject
if (isset($this->headers['Subject'])) {
$mail->subject = ezcMailTools::mimeDecode($this->headers['Subject']);
$mail->subjectCharset = 'utf-8';
}
// message ID
if (isset($this->headers['Message-Id'])) {
$mail->messageID = $this->headers['Message-Id'];
}
// Return-Path
if (isset($this->headers['Return-Path'])) {
$mail->returnPath = ezcMailTools::parseEmailAddress($this->headers['Return-Path']);
}
if ($this->bodyParser !== null) {
$mail->body = $this->bodyParser->finish();
}
return $mail;
}
示例4: array
<?php
require_once 'tutorial_autoload.php';
$mailAddresses = array(new ezcMailAddress('john@example.com', 'Jøhn Doe', 'ISO-8859-1'), new ezcMailAddress('jane@example.com', 'Jane Doe'));
$addresses = '=?ISO-8859-1?B?SsO4aG4gRG9l?= <john@example.com>, Jane Doe <jane@example.com';
// 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('john.doe@example.com');
// 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 'postmaster@example.com', it is used in a
// 'MAIL FROM' SMTP command to validate against MX records
ezcMailTools::$mxValidateAddress = 'email.address@mail.server';
$isValid = ezcMailTools::validateEmailAddress('john.doe@example.com', 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");