本文整理汇总了PHP中mail_encode函数的典型用法代码示例。如果您正苦于以下问题:PHP mail_encode函数的具体用法?PHP mail_encode怎么用?PHP mail_encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mail_encode函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: format_address
function format_address($address)
{
foreach ($address as $array) {
$array['name'] = trim($array['name']);
$formatted[] = $array['name'] && $this->named_addresses ? '"' . mail_encode($array['name'], $this->encoding) . '" <' . $array['address'] . '>' : $array['address'];
}
return implode(', ', $formatted);
}
示例2: process
/**
* Process queue
* Using lock file
*/
function process()
{
global $db, $config, $phpEx, $phpbb_root_path, $user;
set_config('last_queue_run', time(), true);
// Delete stale lock file
if (file_exists($this->cache_file . '.lock') && !file_exists($this->cache_file)) {
@unlink($this->cache_file . '.lock');
return;
}
if (!file_exists($this->cache_file) || file_exists($this->cache_file . '.lock') && filemtime($this->cache_file) > time() - $config['queue_interval']) {
return;
}
$fp = @fopen($this->cache_file . '.lock', 'wb');
fclose($fp);
@chmod($this->cache_file . '.lock', 0777);
include $this->cache_file;
foreach ($this->queue_data as $object => $data_ary) {
@set_time_limit(0);
if (!isset($data_ary['package_size'])) {
$data_ary['package_size'] = 0;
}
$package_size = $data_ary['package_size'];
$num_items = !$package_size || sizeof($data_ary['data']) < $package_size ? sizeof($data_ary['data']) : $package_size;
// If the amount of emails to be sent is way more than package_size than we need to increase it to prevent backlogs...
if (sizeof($data_ary['data']) > $package_size * 2.5) {
$num_items = sizeof($data_ary['data']);
}
switch ($object) {
case 'email':
// Delete the email queued objects if mailing is disabled
if (!$config['email_enable']) {
unset($this->queue_data['email']);
continue 2;
}
break;
case 'jabber':
if (!$config['jab_enable']) {
unset($this->queue_data['jabber']);
continue 2;
}
include_once $phpbb_root_path . 'includes/functions_jabber.' . $phpEx;
$this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], $config['jab_password'], $config['jab_use_ssl']);
if (!$this->jabber->connect()) {
messenger::error('JABBER', $user->lang['ERR_JAB_CONNECT']);
continue 2;
}
if (!$this->jabber->login()) {
messenger::error('JABBER', $user->lang['ERR_JAB_AUTH']);
continue 2;
}
break;
default:
return;
}
for ($i = 0; $i < $num_items; $i++) {
// Make variables available...
extract(array_shift($this->queue_data[$object]['data']));
switch ($object) {
case 'email':
$err_msg = '';
$to = !$to ? 'undisclosed-recipients:;' : $to;
if ($config['smtp_delivery']) {
$result = smtpmail($addresses, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $err_msg, $headers);
} else {
ob_start();
$result = $config['email_function_name']($to, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers);
$err_msg = ob_get_clean();
}
if (!$result) {
@unlink($this->cache_file . '.lock');
messenger::error('EMAIL', $err_msg);
continue 2;
}
break;
case 'jabber':
foreach ($addresses as $address) {
if ($this->jabber->send_message($address, $msg, $subject) === false) {
messenger::error('JABBER', $this->jabber->get_log());
continue 3;
}
}
break;
}
}
// No more data for this object? Unset it
if (!sizeof($this->queue_data[$object]['data'])) {
unset($this->queue_data[$object]);
}
// Post-object processing
switch ($object) {
case 'jabber':
// Hang about a couple of secs to ensure the messages are
// handled, then disconnect
$this->jabber->disconnect();
break;
}
//.........这里部分代码省略.........
示例3: identity_basic_export
//.........这里部分代码省略.........
}
// All other term types will be included in items, if requested.
$r = q("select * from term where type in (%d,%d) and uid = %d", intval(TERM_SAVEDSEARCH), intval(TERM_THING), intval($channel_id));
if ($r) {
$ret['term'] = $r;
}
// add psuedo-column obj_baseurl to aid in relocations
$r = q("select obj.*, '%s' as obj_baseurl from obj where obj_channel = %d", dbesc(z_root()), intval($channel_id));
if ($r) {
$ret['obj'] = $r;
}
$r = q("select * from app where app_channel = %d", intval($channel_id));
if ($r) {
$ret['app'] = $r;
}
$r = q("select * from chatroom where cr_uid = %d", intval($channel_id));
if ($r) {
$ret['chatroom'] = $r;
}
$r = q("select * from event where uid = %d", intval($channel_id));
if ($r) {
$ret['event'] = $r;
}
$r = q("select * from item where resource_type = 'event' and uid = %d", intval($channel_id));
if ($r) {
$ret['event_item'] = array();
xchan_query($r);
$r = fetch_post_tags($r, true);
foreach ($r as $rr) {
$ret['event_item'][] = encode_item($rr, true);
}
}
$x = menu_list($channel_id);
if ($x) {
$ret['menu'] = array();
for ($y = 0; $y < count($x); $y++) {
$m = menu_fetch($x[$y]['menu_name'], $channel_id, $ret['channel']['channel_hash']);
if ($m) {
$ret['menu'][] = menu_element($m);
}
}
}
$x = menu_list($channel_id);
if ($x) {
$ret['menu'] = array();
for ($y = 0; $y < count($x); $y++) {
$m = menu_fetch($x[$y]['menu_name'], $channel_id, $ret['channel']['channel_hash']);
if ($m) {
$ret['menu'][] = menu_element($m);
}
}
}
$addon = array('channel_id' => $channel_id, 'data' => $ret);
call_hooks('identity_basic_export', $addon);
$ret = $addon['data'];
if (!$items) {
return $ret;
}
$r = q("select * from likes where channel_id = %d", intval($channel_id));
if ($r) {
$ret['likes'] = $r;
}
$r = q("select * from conv where uid = %d", intval($channel_id));
if ($r) {
for ($x = 0; $x < count($r); $x++) {
$r[$x]['subject'] = base64url_decode(str_rot47($r[$x]['subject']));
}
$ret['conv'] = $r;
}
$r = q("select * from mail where mail.uid = %d", intval($channel_id));
if ($r) {
$m = array();
foreach ($r as $rr) {
xchan_mail_query($rr);
$m[] = mail_encode($rr, true);
}
$ret['mail'] = $m;
}
$r = q("select item_id.*, item.mid from item_id left join item on item_id.iid = item.id where item_id.uid = %d", intval($channel_id));
if ($r) {
$ret['item_id'] = $r;
}
//$key = get_config('system','prvkey');
/** @warning this may run into memory limits on smaller systems */
/** export three months of posts. If you want to export and import all posts you have to start with
* the first year and export/import them in ascending order.
*
* Don't export linked resource items. we'll have to pull those out separately.
*/
$r = q("select * from item where item_wall = 1 and item_deleted = 0 and uid = %d and created > %s - INTERVAL %s and resource_type = '' order by created", intval($channel_id), db_utcnow(), db_quoteinterval('3 MONTH'));
if ($r) {
$ret['item'] = array();
xchan_query($r);
$r = fetch_post_tags($r, true);
foreach ($r as $rr) {
$ret['item'][] = encode_item($rr, true);
}
}
return $ret;
}
示例4: process
/**
* Process queue
* Using lock file
*/
function process()
{
global $db, $config, $phpEx, $phpbb_root_path, $user;
$lock = new \phpbb\lock\flock($this->cache_file);
$lock->acquire();
// avoid races, check file existence once
$have_cache_file = file_exists($this->cache_file);
if (!$have_cache_file || $config['last_queue_run'] > time() - $config['queue_interval']) {
if (!$have_cache_file) {
set_config('last_queue_run', time(), true);
}
$lock->release();
return;
}
set_config('last_queue_run', time(), true);
include $this->cache_file;
foreach ($this->queue_data as $object => $data_ary) {
@set_time_limit(0);
if (!isset($data_ary['package_size'])) {
$data_ary['package_size'] = 0;
}
$package_size = $data_ary['package_size'];
$num_items = !$package_size || sizeof($data_ary['data']) < $package_size ? sizeof($data_ary['data']) : $package_size;
/*
* This code is commented out because it causes problems on some web hosts.
* The core problem is rather restrictive email sending limits.
* This code is nly useful if you have no such restrictions from the
* web host and the package size setting is wrong.
// If the amount of emails to be sent is way more than package_size than we need to increase it to prevent backlogs...
if (sizeof($data_ary['data']) > $package_size * 2.5)
{
$num_items = sizeof($data_ary['data']);
}
*/
switch ($object) {
case 'email':
// Delete the email queued objects if mailing is disabled
if (!$config['email_enable']) {
unset($this->queue_data['email']);
continue 2;
}
break;
case 'jabber':
if (!$config['jab_enable']) {
unset($this->queue_data['jabber']);
continue 2;
}
include_once $phpbb_root_path . 'includes/functions_jabber.' . $phpEx;
$this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], htmlspecialchars_decode($config['jab_password']), $config['jab_use_ssl']);
if (!$this->jabber->connect()) {
$messenger = new messenger();
$messenger->error('JABBER', $user->lang['ERR_JAB_CONNECT']);
continue 2;
}
if (!$this->jabber->login()) {
$messenger = new messenger();
$messenger->error('JABBER', $user->lang['ERR_JAB_AUTH']);
continue 2;
}
break;
default:
$lock->release();
return;
}
for ($i = 0; $i < $num_items; $i++) {
// Make variables available...
extract(array_shift($this->queue_data[$object]['data']));
switch ($object) {
case 'email':
$err_msg = '';
$to = !$to ? 'undisclosed-recipients:;' : $to;
if ($config['smtp_delivery']) {
$result = smtpmail($addresses, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $err_msg, $headers);
} else {
$result = phpbb_mail($to, $subject, $msg, $headers, $this->eol, $err_msg);
}
if (!$result) {
$messenger = new messenger();
$messenger->error('EMAIL', $err_msg);
continue 2;
}
break;
case 'jabber':
foreach ($addresses as $address) {
if ($this->jabber->send_message($address, $msg, $subject) === false) {
$messenger = new messenger();
$messenger->error('JABBER', $this->jabber->get_log());
continue 3;
}
}
break;
}
}
// No more data for this object? Unset it
if (!sizeof($this->queue_data[$object]['data'])) {
//.........这里部分代码省略.........
示例5: mail_send
/**
* Отправить HTML письмо
*
* @param string $to Кому
* @param string $from От кого
* @param string $message Письмо
* @param string $subject Тема письма
*/
function mail_send($to, $from = 'info@samsonos.com', $message = '', $subject = '', $from_user = '')
{
// Обработаем кирилицу в поле: От кого
$from_user = mail_encode($from_user, 'UTF-8');
// Обработаем кирилицу в поле: Тема письма
$subject = mail_encode($subject, 'UTF-8');
// Uniqid Session
$session = md5(uniqid(time()));
// Установим необходимые заголовки
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset="UTF-8"' . "\r\n";
//"Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
//$strHeader .= "This is a multi-part message in MIME format.\n";
$headers .= 'From: ' . $from_user . '<' . $from . '>' . "\r\n";
// Добавим в сообщение HTML тэги
$message = '<html><head><meta charset="utf-8"></head><body>' . $message . '</body></html>';
// Если письмо отправленно вернем 1
return mail($to, $subject, $message, $headers);
}
示例6: format_address
function format_address($address, $header = false)
{
if ($header) {
return $address['name'] && $this->named_addresses ? '"' . mail_encode($address['name'], $this->encoding) . '" <' . $address['address'] . '>' : $address['address'];
}
//return ($address['name'] && $this->named_addresses) ? '<' . $address['address'] . '> '.$address['name'] : '<' . $address['address'] . '>';
return '<' . $address['address'] . '>';
}
示例7: msg_email
/**
* Send out emails
*/
function msg_email($is_html = false)
{
global $config;
if (empty($config['email_enable'])) {
return false;
}
// Addresses to send to?
if (empty($this->addresses) || empty($this->addresses['to']) && empty($this->addresses['cc']) && empty($this->addresses['bcc'])) {
// Send was successful. ;)
return true;
}
$contact_name = htmlspecialchars_decode($config['board_contact_name']);
$board_contact = ($contact_name !== '' ? '"' . mail_encode($contact_name) . '" ' : '') . '<' . $config['board_contact'] . '>';
if (empty($this->replyto)) {
$this->replyto = $board_contact;
}
if (empty($this->from)) {
$this->from = $board_contact;
}
$encode_eol = $config['smtp_delivery'] ? "\r\n" : $this->eol;
// Build to, cc and bcc strings
$to = $cc = $bcc = '';
foreach ($this->addresses as $type => $address_ary) {
if ($type == 'im') {
continue;
}
foreach ($address_ary as $which_ary) {
${$type} .= (${$type} != '' ? ', ' : '') . ($which_ary['name'] != '' ? mail_encode($which_ary['name'], $encode_eol) . ' <' . $which_ary['email'] . '>' : $which_ary['email']);
}
}
// Build header
$headers = $this->build_header($to, $cc, $bcc, $is_html);
// Send message ...
$mail_to = $to == '' ? 'undisclosed-recipients:;' : $to;
$err_msg = '';
if ($config['smtp_delivery']) {
$result = smtpmail($this->addresses, mail_encode($this->subject), wordwrap(utf8_wordwrap($this->msg), 997, "\n", true), $err_msg, $headers);
} else {
$result = phpbb_mail($mail_to, $this->subject, $this->msg, $headers, $this->eol, $err_msg);
}
if (!$result) {
$this->error('EMAIL', $err_msg);
return false;
}
return true;
}
示例8: mail_digests
//.........这里部分代码省略.........
$powered_by = sprintf("<a href=\"%s\">%s</a>", $this->config['phpbbservices_digests_page_url'], $this->config['phpbbservices_digests_host']);
$this->layout_with_html_tables = true;
break;
default:
// The database may be corrupted if the digest format for a subscriber is invalid.
// Write an error to the log and continue to the next subscriber.
$format = '';
// Keep PhpStorm happy
$is_html = false;
// Keep PhpStorm happy
$disclaimer = '';
// Keep PhpStorm happy
$powered_by = '';
// Keep PhpStorm happy
$this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_CONFIG_DIGESTS_FORMAT_ERROR', false, array($row['user_digest_type'], $row['username']));
continue;
break;
}
// Set email header information
$from_field_email = isset($this->config['phpbbservices_digests_from_email_address']) && strlen($this->config['phpbbservices_digests_from_email_address']) > 0 ? $this->config['phpbbservices_digests_from_email_address'] : $this->config['board_email'];
$from_field_name = isset($this->config['phpbbservices_digests_from_email_name']) && strlen($this->config['phpbbservices_digests_from_email_name']) > 0 ? $this->config['phpbbservices_digests_from_email_name'] : $this->config['sitename'] . ' ' . $this->user->lang['DIGESTS_ROBOT'];
$reply_to_field_email = isset($this->config['phpbbservices_digests_reply_to_email_address']) && strlen($this->config['phpbbservices_digests_reply_to_email_address']) > 0 ? $this->config['phpbbservices_digests_reply_to_email_address'] : $this->config['board_email'];
// Admin may override where email is sent in manual mode. This won't apply if digests are stored to the store/phpbbservices/digests folder instead.
if ($this->manual_mode && $this->config['phpbbservices_digests_test_send_to_admin']) {
$html_messenger->to($this->email_address_override);
} else {
$html_messenger->to($row['user_email']);
}
// SMTP delivery must strip text names due to likely bug in messenger class
if ($this->config['smtp_delivery']) {
$html_messenger->from($from_field_email);
} else {
if (trim($from_field_name) !== '') {
$html_messenger->from(mail_encode(htmlspecialchars_decode($from_field_name)) . ' <' . $from_field_email . '>');
} else {
$html_messenger->from($from_field_email);
}
}
$html_messenger->replyto($reply_to_field_email);
$html_messenger->subject($email_subject);
// Transform user_digest_send_hour_gmt to the subscriber's local time
$local_send_hour = $row['user_digest_send_hour_gmt'] + (int) $this->helper->make_tz_offset($row['user_timezone'], $row['username']);
if ($local_send_hour >= 24) {
$local_send_hour = $local_send_hour - 24;
} else {
if ($local_send_hour < 0) {
$local_send_hour = $local_send_hour + 24;
}
}
if ($local_send_hour >= 24 || $local_send_hour < 0) {
// The database may be corrupted if the local send hour for a subscriber is still not between 0 and 23.
// Write an error to the log and continue to the next subscriber.
$this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_CONFIG_DIGESTS_BAD_SEND_HOUR', false, array($row['user_digest_type'], $row['user_digest_send_hour_gmt']));
continue;
}
// Change the filter type into something human readable
switch ($row['user_digest_filter_type']) {
case constants::DIGESTS_ALL:
$post_types = $this->user->lang['DIGESTS_POSTS_TYPE_ANY'];
break;
case constants::DIGESTS_FIRST:
$post_types = $this->user->lang['DIGESTS_POSTS_TYPE_FIRST'];
break;
case constants::DIGESTS_BOOKMARKS:
$post_types = $this->user->lang['DIGESTS_USE_BOOKMARKS'];
break;
示例9: msg_email
function msg_email()
{
global $config, $_CLASS;
if (empty($config['email_enable'])) {
return false;
}
$use_queue = false;
if ($config['email_package_size'] && $this->use_queue) {
if (empty($this->queue)) {
$this->queue = new queue();
$this->queue->init('email', $config['email_package_size']);
}
$use_queue = true;
}
$to = $cc = $bcc = '';
// Build to, cc and bcc strings
foreach ($this->addresses as $type => $address_ary) {
if ($type == 'im') {
continue;
}
foreach ($address_ary as $which_ary) {
${$type} .= (${$type} != '' ? ', ' : '') . ($which_ary['name'] != '' ? '"' . mail_encode($which_ary['name'], $this->encoding) . '" <' . $which_ary['email'] . '>' : $which_ary['email']);
}
}
if (empty($this->replyto)) {
$this->replyto = '<' . $config['board_email'] . '>';
}
if (empty($this->from)) {
$this->from = '<' . $config['board_email'] . '>';
}
// Build header
$headers = 'From: ' . $this->from . "\n";
$headers .= $cc != '' ? "Cc: {$cc}\n" : '';
$headers .= $bcc != '' ? "Bcc: {$bcc}\n" : '';
$headers .= 'Reply-to: ' . $this->replyto . "\n";
$headers .= 'Return-Path: <' . $config['board_email'] . ">\n";
$headers .= 'Sender: <' . $config['board_email'] . ">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= 'Message-ID: <' . md5(uniqid(time())) . "@" . $config['server_name'] . ">\n";
$headers .= 'Date: ' . gmdate('D, d M Y H:i:s T', time()) . "\n";
$headers .= "Content-type: text/plain; charset={$this->encoding}\n";
$headers .= "Content-transfer-encoding: 8bit\n";
$headers .= "X-Priority: {$this->mail_priority}\n";
$headers .= 'X-MSMail-Priority: ' . ($this->mail_priority == MAIL_LOW_PRIORITY ? 'Low' : ($this->mail_priority == MAIL_NORMAL_PRIORITY ? 'Normal' : 'High')) . "\n";
$headers .= "X-Mailer: PhpBB\n";
$headers .= "X-MimeOLE: phpBB\n";
$headers .= "X-phpBB-Origin: phpbb://" . str_replace(array('http://', 'https://'), array('', ''), generate_board_url()) . "\n";
$headers .= $this->extra_headers != '' ? $this->extra_headers : '';
// Send message ... removed $this->encode() from subject for time being
if (!$use_queue) {
$mail_to = $to == '' ? 'Undisclosed-Recipient:;' : $to;
$err_msg = '';
$result = $config['smtp_delivery'] ? smtpmail($this->addresses, $this->subject, wordwrap($this->msg), $err_msg, $this->encoding, $headers) : @$config['email_function_name']($mail_to, $this->subject, implode("\n", preg_split("/\r?\n/", wordwrap($this->msg))), $headers);
if (!$result) {
$message = '<u>EMAIL ERROR</u> [ ' . ($config['smtp_delivery'] ? 'SMTP' : 'PHP') . ' ]<br /><br />' . $err_msg . '<br /><br /><u>CALLING PAGE</u><br /><br />' . (!empty($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF']) . '<br />';
$this->error('EMAIL', $message);
return false;
}
} else {
$this->queue->put('email', array('to' => $to, 'addresses' => $this->addresses, 'subject' => $this->subject, 'msg' => $this->msg, 'encoding' => $this->encoding, 'headers' => $headers));
}
return true;
}
示例10: foreach
foreach ($data[attachment_data] as $filename) {
$message .= " " . print_r($filename, 1) . "\n";
}
$message .= "\n";
}
// add signature
if ($n2m_SHOW_SIG) {
if ($mode != "edit") {
if ($user->data[user_sig] and $data[enable_sig]) {
$message .= "\nSignature:\n ";
$message .= generate_text_for_edit($user->data[user_sig], $user->data[user_sig_bbcode_uid], $post_data[forum_desc_options])["text"] . "\n\n";
}
}
}
// encode subject
$subject = mail_encode(html_entity_decode($n2m_SUBJECT));
// convert all addresses to lowercase and delete any empty addresses
foreach ($n2m_MAILTO as $key => $value) {
if (is_null($value) or $value == "") {
unset($n2m_MAILTO[$key]);
} else {
$n2m_MAILTO[$key] = strtolower($n2m_MAILTO[$key]);
}
}
// insure that every address is only used once
$n2m_MAILTO = array_unique($n2m_MAILTO);
// Testversion, Mails an Author des Artikels verhindern
// unset($n2m_MAILTO[array_search($user->data['user_email'], $n2m_MAILTO)]);
// die($message); // for debugging purposes, mail will be shown in browser and not sent out if we uncomment this line
// make text "flow" in plain/text
$temp = $message;