本文整理汇总了PHP中ezcMailTools::parseEmailAddress方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcMailTools::parseEmailAddress方法的具体用法?PHP ezcMailTools::parseEmailAddress怎么用?PHP ezcMailTools::parseEmailAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezcMailTools
的用法示例。
在下文中一共展示了ezcMailTools::parseEmailAddress方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
public static function send($to, $subject, $body, $options = array())
{
$siteINI = eZINI::instance('site.ini');
$i18nINI = eZINI::instance('i18n.ini');
$transport = $siteINI->variable('MailSettings', 'Transport');
$charset = $i18nINI->variable('CharacterSettings', 'Charset');
$emailSender = $siteINI->variable('MailSettings', 'EmailSender');
if (!$emailSender) {
$emailSender = $siteINI->variable('MailSettings', 'AdminEmail');
}
if ($transport == 'SMTP') {
$mailTransport = new ezcMailSmtpTransport($siteINI->variable('MailSettings', 'TransportServer'), $siteINI->variable('MailSettings', 'TransportUser'), $siteINI->variable('MailSettings', 'TransportPassword'), $siteINI->variable('MailSettings', 'TransportPort'));
} else {
eZDebug::writeError('Only SMTP Transport supported', 'jajNewsletterSubscription::sendConfirmationMail');
throw new Exception('Only SMTP Transport supported');
}
$mail = new ezcMailComposer();
$mail->charset = $charset;
$mail->subjectCharset = $charset;
$mail->subject = $subject;
$mail->htmlText = $body;
$mail->from = ezcMailTools::parseEmailAddress($emailSender, $charset);
$mail->addTo(new ezcMailAddress($to, '', $charset));
$mail->build();
$mailTransport->send($mail);
}
示例2: 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;
}
示例3: testParseEmailAddressLocalEncoding
public function testParseEmailAddressLocalEncoding()
{
$add = ezcMailTools::parseEmailAddress('Test äöää <foobar@example.com>', 'iso-8859-1');
$this->assertEquals('Test äöää', $add->name);
$this->assertEquals('foobar@example.com', $add->email);
}
示例4: sendConfirmationMail
function sendConfirmationMail($list)
{
$tpl = eZTemplate::factory();
$template = 'design:jaj_newsletter/subscription/mail/confirm.tpl';
$siteINI = eZINI::instance('site.ini');
$i18nINI = eZINI::instance('i18n.ini');
$transport = $siteINI->variable('MailSettings', 'Transport');
$charset = $i18nINI->variable('CharacterSettings', 'Charset');
$emailSender = $siteINI->variable('MailSettings', 'EmailSender');
if (!$emailSender) {
$emailSender = $siteINI->variable('MailSettings', 'AdminEmail');
}
if ($transport == 'SMTP') {
$mailTransport = new ezcMailSmtpTransport($siteINI->variable('MailSettings', 'TransportServer'), $siteINI->variable('MailSettings', 'TransportUser'), $siteINI->variable('MailSettings', 'TransportPassword'), $siteINI->variable('MailSettings', 'TransportPort'));
} else {
eZDebug::writeError('Only SMTP Transport supported', 'jajNewsletterSubscription::sendConfirmationMail');
throw new Exception('Only SMTP Transport supported');
}
$tpl->setVariable('subscription', $this);
$tpl->setVariable('list', $list);
$tpl->setVariable('hostname', eZSys::hostname());
$templateResult = $tpl->fetch($template);
$subject = "Please confirm your newsletter subscription";
if ($tpl->hasVariable('subject')) {
$subject = $tpl->variable('subject');
}
$mail = new ezcMailComposer();
$mail->charset = $charset;
$mail->subjectCharset = $charset;
$mail->subject = $subject;
$mail->plainText = $templateResult;
$mail->from = ezcMailTools::parseEmailAddress($emailSender, $charset);
$mail->addTo(new ezcMailAddress($this->Email, $this->Name, $charset));
$mail->build();
$mailTransport->send($mail);
}
示例5: 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");