本文整理汇总了PHP中eZMail::extractEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP eZMail::extractEmail方法的具体用法?PHP eZMail::extractEmail怎么用?PHP eZMail::extractEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZMail
的用法示例。
在下文中一共展示了eZMail::extractEmail方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendMail
function sendMail(eZMail $mail)
{
$ini = eZINI::instance();
$parameters = array();
$parameters['host'] = $ini->variable('MailSettings', 'TransportServer');
$parameters['helo'] = $ini->variable('MailSettings', 'SenderHost');
$parameters['port'] = $ini->variable('MailSettings', 'TransportPort');
$parameters['connectionType'] = $ini->variable('MailSettings', 'TransportConnectionType');
$user = $ini->variable('MailSettings', 'TransportUser');
$password = $ini->variable('MailSettings', 'TransportPassword');
if ($user and $password) {
$parameters['auth'] = true;
$parameters['user'] = $user;
$parameters['pass'] = $password;
}
/* If email sender hasn't been specified or is empty
* we substitute it with either MailSettings.EmailSender or AdminEmail.
*/
if (!$mail->senderText()) {
$emailSender = $ini->variable('MailSettings', 'EmailSender');
if (!$emailSender) {
$emailSender = $ini->variable('MailSettings', 'AdminEmail');
}
eZMail::extractEmail($emailSender, $emailSenderAddress, $emailSenderName);
if (!eZMail::validate($emailSenderAddress)) {
$emailSender = false;
}
if ($emailSender) {
$mail->setSenderText($emailSender);
}
}
$excludeHeaders = $ini->variable('MailSettings', 'ExcludeHeaders');
if (count($excludeHeaders) > 0) {
$mail->Mail->appendExcludeHeaders($excludeHeaders);
}
$options = new ezcMailSmtpTransportOptions();
if ($parameters['connectionType']) {
$options->connectionType = $parameters['connectionType'];
}
$smtp = new ezcMailSmtpTransport($parameters['host'], $user, $password, $parameters['port'], $options);
// If in debug mode, send to debug email address and nothing else
if ($ini->variable('MailSettings', 'DebugSending') == 'enabled') {
$mail->Mail->to = array(new ezcMailAddress($ini->variable('MailSettings', 'DebugReceiverEmail')));
$mail->Mail->cc = array();
$mail->Mail->bcc = array();
}
// send() from ezcMailSmtpTransport doesn't return anything (it uses exceptions in case
// something goes bad)
try {
eZPerfLogger::accumulatorStart('mail_sent');
$smtp->send($mail->Mail);
eZPerfLogger::accumulatorStop('mail_sent');
} catch (ezcMailException $e) {
eZPerfLogger::accumulatorStop('mail_send');
eZDebug::writeError($e->getMessage(), __METHOD__);
return false;
}
// return true in case of no exceptions
return true;
}
示例2: testExtractEmail
/**
* @dataProvider providerTestExtractEmail
*/
public function testExtractEmail($recipient, $name, $email)
{
eZMail::extractEmail($recipient, $extractedEmail, $extractedName);
self::assertEquals($extractedEmail, $email);
self::assertEquals($extractedName, $name);
}
示例3: microtime_float2
$time_start = microtime_float2();
$smtp = getConnection($active_server, $serverlist);
$allowPersistent = $mailSettings->variable('SMTPClusterSettings', 'PersistentConnection') == 'enabled' ? true : false;
for ($i = 0; $i < count($mailFiles); $i++) {
// sending message
$email = file_get_contents($mailFiles[$i]);
$lines = file($mailFiles[$i]);
// get from and to
$regex = regexEmail();
$expression = "/({$regex})/";
preg_match_all($expression, $lines[1], $matches);
$from_address = array_pop($matches[1]);
preg_match_all($expression, $lines[7], $matches);
$to_address = array_pop($matches[1]);
eZMail::extractEmail($from_address, $from, $name);
eZMail::extractEmail($to_address, $to, $name);
if (eZMail::validate($from) && eZMail::validate($to)) {
if ($smtp->send($from, $to, $email)) {
$cli->output(".", false);
// rename file on hdd
eZFile::rename($mailFiles[$i], $mailFiles[$i] . ".send");
if (!$allowPersistent) {
$smtp->quit();
$smtp = getConnection($active_server, $serverlist);
}
} else {
if (count($serverlist) > 1) {
// retrying other server
$active_server = nextConnection($active_server, $serverlist, $i + 1);
$smtp = getConnection($active_server, $serverlist);
$try = 1;
示例4: unsubscribe
function unsubscribe($address_string, $list_name)
{
$subscription_list = eZSubscriptionList::fetch($list_name);
eZMail::extractEmail($address_string, $email, $name);
if ($email) {
$subscription = eZSubscription::fetchByEmailSubscriptionListID($email, $subscription_list->attribute('id'));
if ($subscription) {
if ($subscription->attribute('status') == eZSubscription::StatusApproved) {
$subscription->setAttribute('status', eZSubscription::StatusRemovedSelf);
$subscription->sync();
return $subscription;
}
}
}
return false;
}