本文整理匯總了PHP中email::to方法的典型用法代碼示例。如果您正苦於以下問題:PHP email::to方法的具體用法?PHP email::to怎麽用?PHP email::to使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類email
的用法示例。
在下文中一共展示了email::to方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: sendEmail
public function sendEmail()
{
global $mysql, $langArray, $user, $config;
if (!isset($_POST['message']) || trim($_POST['message']) == '') {
return $langArray['error_not_set_message'];
}
$mysql->query("\n\t\t\tINSERT INTO `users_emails` (\n\t\t\t\t`from_id`,\n\t\t\t\t`from_email`,\n\t\t\t\t`to_id`,\n\t\t\t\t`message`,\n\t\t\t\t`datetime`\n\t\t\t)\n\t\t\tVALUES (\n\t\t\t\t'" . intval($_SESSION['user']['user_id']) . "',\n\t\t\t\t'" . sql_quote($_SESSION['user']['email']) . "',\n\t\t\t\t'" . intval($user['user_id']) . "',\n\t\t\t\t'" . sql_quote($_POST['message']) . "',\n\t\t\t\tNOW()\n\t\t\t)\n\t\t");
#發送郵件
require_once ENGINE_PATH . '/classes/email.class.php';
$emailClass = new email();
$emailClass->fromEmail = 'no-reply@' . $config['domain'];
$emailClass->subject = '[' . $config['domain'] . '] ' . $langArray['email_profile_subject'];
$emailClass->message = langMessageReplace($langArray['email_profile_text'], array('USERNAME' => $_SESSION['user']['username'], 'EMAIL' => $_SESSION['user']['email'], 'MESSAGE' => $_POST['message']));
$emailClass->to($user['email']);
$emailClass->send();
unset($emailClass);
return true;
}
示例2: add
public function add()
{
global $mysql, $langArray, $config;
if (!isset($_POST['name']) || trim($_POST['name']) == '') {
$error['name'] = $langArray['error_fill_this_field'];
}
if (!isset($_POST['text']) || trim($_POST['text']) == '') {
$error['text'] = $langArray['error_fill_this_field'];
}
if (!isset($_POST['send_to']) || trim($_POST['send_to']) == '') {
$error['send_to'] = $langArray['error_fill_this_field'];
}
if (isset($_POST['send_to']) && $_POST['send_to'] == 'city' && (!isset($_POST['city_id']) || !is_numeric($_POST['city_id']))) {
$error['city'] = $langArray['error_fill_this_field'];
}
if (isset($_POST['send_to']) && $_POST['send_to'] == 'group' && (!isset($_POST['bgroup_id']) || !is_numeric($_POST['bgroup_id']))) {
$error['group'] = $langArray['error_fill_this_field'];
}
if (isset($error)) {
return $error;
}
$sendID = 0;
if ($_POST['send_to'] == 'city') {
$sendID = $_POST['city_id'];
} elseif ($_POST['send_to'] == 'group') {
$sendID = $_POST['bgroup_id'];
}
$mysql->query("\n\t\t\tINSERT INTO `bulletin` (\n\t\t\t\t`name`,\n\t\t\t\t`text`,\n\t\t\t\t`datetime`,\n\t\t\t\t`send_to`,\n\t\t\t\t`send_id`\n\t\t\t)\n\t\t\tVALUES (\n\t\t\t\t'" . sql_quote($_POST['name']) . "',\n\t\t\t\t'" . sql_quote($_POST['text']) . "',\n\t\t\t\tNOW(),\n\t\t\t\t'" . sql_quote($_POST['send_to']) . "',\n\t\t\t\t'" . intval($sendID) . "'\n\t\t\t)\n\t\t", __FUNCTION__);
$bulletinID = $mysql->insert_id();
#加載訂閱列表
if ($_POST['send_to'] == 'city') {
$mysql->query("\n\t\t\t\tSELECT *\n\t\t\t\tFROM `users`\n\t\t\t\tWHERE `city_id` = '" . intval($_POST['city_id']) . "' AND `bulletin_subscribe` = 'true'\n\t\t\t");
if ($mysql->num_rows() > 0) {
while ($d = $mysql->fetch_array()) {
$emails[] = $d['email'];
}
}
}
#加載分組
if ($_POST['send_to'] == 'group') {
$mysql->query("\n\t\t\t\tSELECT u.*\n\t\t\t\tFROM `bulletin_users` AS bg\t\t\t\t\n\t\t\t\tJOIN `users` AS u\n\t\t\t\tON u.`user_id` = bg.`user_id` AND u.`bulletin_subscribe` = 'true'\n\t\t\t\tWHERE bg.`bulletingroup_id` = '" . intval($_POST['bgroup_id']) . "'\n\t\t\t");
if ($mysql->num_rows() > 0) {
while ($d = $mysql->fetch_array()) {
$emails[] = $d['email'];
}
}
}
#加載全部
if ($_POST['send_to'] == 'active') {
$mysql->query("\n\t\t\t\tSELECT *\n\t\t\t\tFROM `users`\n\t\t\t\tWHERE `bulletin_subscribe` = 'true'\n\t\t\t");
if ($mysql->num_rows() > 0) {
while ($d = $mysql->fetch_array()) {
$emails[] = $d['email'];
}
}
}
#加載全部
if ($_POST['send_to'] == 'admins') {
$mysql->query("\n\t\t\t\tSELECT *\n\t\t\t\tFROM `admins`\n\t\t\t\tWHERE `bulletin_subscribe` = 'true'\n\t\t\t");
if ($mysql->num_rows() > 0) {
while ($d = $mysql->fetch_array()) {
$emails[] = $d['email'];
}
}
}
#加載全部
if ($_POST['send_to'] == 'site') {
$mysql->query("\n\t\t\t\tSELECT *\n\t\t\t\tFROM `bulletin_emails`\n\t\t\t\tWHERE `bulletin_subscribe` = 'true'\n\t\t\t");
if ($mysql->num_rows() > 0) {
while ($d = $mysql->fetch_array()) {
$emails[] = $d['email'];
}
}
}
#獲取模板
$mysql->query("\n\t\t\tSELECT *\n\t\t\tFROM `bulletin_template`\n\t\t\tORDER BY `id` DESC\n\t\t\tLIMIT 1\n\t\t");
if ($mysql->num_rows() > 0) {
$template = $mysql->fetch_array();
$template = $template['template'];
} else {
$template = '{$CONTENT}';
}
if (isset($emails)) {
require_once $config['system_core'] . 'classes/email.class.php';
foreach ($emails as $email) {
$mail = new email();
$mail->fromEmail = 'no-reply@' . $config['domain'];
$mail->to($email);
$mail->subject = '[' . $config['domain'] . '] ' . $_POST['name'];
$mail->contentType = 'text/html';
$mail->message = langMessageReplace($template, array('DOMAIN' => $config['domain'], 'BULLETINID' => $bulletinID, 'EMAIL' => $email, 'CONTENT' => $_POST['text']));
require_once ROOT_PATH . '/apps/system/models/system.class.php';
$system = new system();
$smtp = $system->is_smtp();
$smtpconf = $system->getAllKeyValue();
if ($smtp) {
$mail->email_sock($smtpconf["smtp_host"], $smtpconf["smtp_port"], 0, 'error', 10, 1, $smtpconf["smtp_user"], $smtpconf["smtp_pass"], $smtpconf["smtp_from"]);
$mail->send_mail_sock($mail->subject, $mail->message, $email, $smtpconf["smtp_from_name"]);
unset($emailClass);
} else {
//.........這裏部分代碼省略.........
示例3: report
public function report($id)
{
global $mysql, $langArray;
$mysql->query("\n\t\t\tUPDATE `items_comments`\n\t\t\tSET `report_by` = '" . intval($_SESSION['user']['user_id']) . "'\n\t\t\tWHERE `id` = '" . intval($id) . "'\n\t\t\tLIMIT 1\n\t\t");
#給管理員發送電子郵件
$mysql->query("\n\t\t\tSELECT *\n\t\t\tFROM `system`\n\t\t\tWHERE `key` = 'admin_mail' OR `key` = 'report_mail'\n\t\t");
while ($d = $mysql->fetch_array()) {
if ($d['key'] == 'report_mail') {
$sendTo = $d['value'];
break;
}
$sendTo = $d['value'];
}
$emailClass = new email();
$emailClass->to($sendTo);
$emailClass->fromEmail = 'no-reply@' . DOMAIN;
$emailClass->contentType = 'text/html';
$emailClass->subject = "[" . DOMAIN . "] " . $langArray['email_report_comment_subject'];
$emailClass->message = $_SESSION['user']['username'] . $langArray['email_report_comment_text'];
$emailClass->send();
unset($emailClass);
return true;
}
示例4: sendAnswer
public function sendAnswer()
{
global $mysql, $langArray, $data;
if (!isset($_POST['answer']) || trim($_POST['answer']) == '') {
$error['answer'] = $langArray['error_not_set_name'];
}
if (isset($error)) {
return $error;
}
$mysql->query("\n\t\t\tUPDATE `contacts`\n\t\t\tSET `answer` = '" . sql_quote($_POST['answer']) . "',\n\t\t\t\t\t`answer_datetime` = NOW()\n\t\t\tWHERE `id` = '" . intval($data['id']) . "'\n\t\t\tLIMIT 1\n\t\t", __FUNCTION__);
#發送郵件
$emailClass = new email();
$emailClass->to($data['email']);
$emailClass->fromEmail = 'no-reply@' . DOMAIN;
$emailClass->contentType = 'text/plain';
$emailClass->subject = "[" . DOMAIN . "] 聯係表單";
$emailClass->message = $_POST['answer'] . '
' . $data['name'] . ' ' . $langArray['wrote'] . ' =============
' . $data['short_text'];
$emailClass->send();
unset($emailClass);
return true;
}