Exemple #1
0
function send_mail($to, $subject, $message, $from = '', $encoding = 'gbk')
{
    global $mailcfg;
    // Default sender/return address
    if (!$from) {
        $from = SYSTEM_NAME . '<' . $mailcfg['username'] . '>';
    }
    $type = $mailcfg['type'] == 'HTML' ? 'text/html' : 'text/plain';
    // Do a little spring cleaning
    $to = trim(preg_replace('#[\\n\\r]+#s', '', $to));
    $subject = mb_convert_encoding(trim(preg_replace('#[\\n\\r]+#s', '', $subject)), 'gbk', 'utf-8');
    $from = mb_convert_encoding(trim(preg_replace('#[\\n\\r:]+#s', '', $from)), 'gbk', 'utf-8');
    $headers = 'From: ' . $from . "\r\n" . 'Date: ' . date('r') . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-transfer-encoding: 8bit' . "\r\n" . 'Content-type: ' . $type . '; charset=' . $encoding . "\r\n" . 'X-Mailer: Ecosme-Mailer';
    // Make sure all linebreaks are CRLF in message (and strip out any NULL bytes)
    $message = str_replace(array("\n", ""), array("\r\n", ''), linebreaks($message));
    $message = mb_convert_encoding($message, 'gbk', 'utf-8');
    if ($mailcfg['server'] != '') {
        smtp_mail($to, $subject, $message, $headers);
    } else {
        // Change the linebreaks used in the headers according to OS
        if (strtoupper(substr(PHP_OS, 0, 3)) == 'MAC') {
            $headers = str_replace("\r\n", "\r", $headers);
        } else {
            if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
                $headers = str_replace("\r\n", "\n", $headers);
            }
        }
        mail($to, $subject, $message, $headers);
    }
}
Exemple #2
0
function pun_mail($to, $subject, $message, $from = '')
{
    global $pun_config, $lang_common;
    $sender = str_replace('"', '', $pun_config['o_board_title'] . ' ' . $lang_common['Mailer']);
    // Default sender/return address
    if (!$from) {
        $from = '"=?UTF-8?B?' . base64_encode($sender) . '?=" <' . $pun_config['o_webmaster_email'] . '>';
    }
    // Do a little spring cleaning
    $to = trim(preg_replace('#[\\n\\r]+#s', '', $to));
    $subject = trim(preg_replace('#[\\n\\r]+#s', '', $subject));
    $from = trim(preg_replace('#[\\n\\r:]+#s', '', $from));
    $subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
    $headers = 'From: ' . $from . "\r\n" . 'Date: ' . date('r') . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-transfer-encoding: 8bit' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n" . 'X-Mailer: PunBB Mailer';
    // Make sure all linebreaks are CRLF in message (and strip out any NULL bytes)
    $message = str_replace(array("\n", ""), array("\r\n", ''), pun_linebreaks($message));
    if ($pun_config['o_smtp_host']) {
        return smtp_mail($to, $subject, $message, $headers);
    } else {
        // Change the linebreaks used in the headers according to OS
        if (strtoupper(substr(PHP_OS, 0, 3)) == 'MAC') {
            $headers = str_replace("\r\n", "\r", $headers);
        } else {
            if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
                $headers = str_replace("\r\n", "\n", $headers);
            }
        }
        return mail($to, $subject, $message, $headers);
    }
}
function pun_mail($to, $subject, $message, $from = '')
{
    global $pun_config, $lang_common;
    // Default sender/return address
    if (!$from) {
        $from = '"' . str_replace('"', '', $pun_config['o_board_title'] . ' ' . $lang_common['Mailer']) . '" <' . $pun_config['o_webmaster_email'] . '>';
    }
    // Do a little spring cleaning
    $to = trim(preg_replace('#[\\n\\r]+#s', '', $to));
    $subject = trim(preg_replace('#[\\n\\r]+#s', '', $subject));
    $from = trim(preg_replace('#[\\n\\r:]+#s', '', $from));
    // Detect what linebreak we should use for the headers
    if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) {
        $eol = "\r\n";
    } else {
        if (strtoupper(substr(PHP_OS, 0, 3) == 'MAC')) {
            $eol = "\r";
        } else {
            $eol = "\n";
        }
    }
    $headers = 'From: ' . $from . $eol . 'Date: ' . date('r') . $eol . 'MIME-Version: 1.0' . $eol . 'Content-transfer-encoding: 8bit' . $eol . 'Content-type: text/plain; charset=' . $lang_common['lang_encoding'] . $eol . 'X-Mailer: PunBB Mailer';
    // Make sure all linebreaks are CRLF in message
    $message = str_replace("\n", "\r\n", pun_linebreaks($message));
    if ($pun_config['o_smtp_host'] != '') {
        smtp_mail($to, $subject, $message, $headers);
    } else {
        mail($to, $subject, $message, $headers);
    }
}
function cpg_mail($to, $subject, $msg_body, $type = 'text/plain', $sender_name = '', $sender_email = '')
{
    global $CONFIG;
    global $lang_charset;
    if ($sender_name == '') {
        $sender_name = $CONFIG['gallery_name'];
    }
    if ($sender_email == '') {
        $sender_email = $CONFIG['gallery_admin_email'];
    }
    $charset = $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'];
    $extra_headers = "From: {$sender_name} <{$sender_email}>\n" . "MIME-Version: 1.0\n" . "Content-type: {$type}; charset=" . $charset . "\n" . "Content-transfer-encoding: 8bit\n" . "Date: " . gmdate('D, d M Y H:i:s', time()) . " UT\n" . "X-Priority: 3 (Normal)\n" . "X-MSMail-Priority: Normal\n" . "X-Mailer: Coppermine Photo Gallery\n" . "Importance: Normal";
    // Fix any bare linefeeds in the message to make it RFC821 Compliant.
    $message = preg_replace("/(?<!\r)\n/si", "\r\n", $msg_body);
    if (empty($CONFIG['smtp_host'])) {
        return mail($to, $subject, $msg_body, $extra_headers);
    } else {
        return smtp_mail($to, $subject, $msg_body, $extra_headers);
    }
}
function forum_mail($to, $subject, $message, $reply_to_email = '', $reply_to_name = '')
{
    global $forum_config, $lang_common;
    // Default sender address
    $from_name = sprintf($lang_common['Forum mailer'], $forum_config['o_board_title']);
    $from_email = $forum_config['o_webmaster_email'];
    ($hook = get_hook('em_fn_forum_mail_start')) ? eval($hook) : null;
    // Do a little spring cleaning
    $to = forum_trim(preg_replace('#[\\n\\r]+#s', '', $to));
    $subject = forum_trim(preg_replace('#[\\n\\r]+#s', '', $subject));
    $from_email = forum_trim(preg_replace('#[\\n\\r:]+#s', '', $from_email));
    $from_name = forum_trim(preg_replace('#[\\n\\r:]+#s', '', str_replace('"', '', $from_name)));
    $reply_to_email = forum_trim(preg_replace('#[\\n\\r:]+#s', '', $reply_to_email));
    $reply_to_name = forum_trim(preg_replace('#[\\n\\r:]+#s', '', str_replace('"', '', $reply_to_name)));
    // Set up some headers to take advantage of UTF-8
    $from = "=?UTF-8?B?" . base64_encode($from_name) . "?=" . ' <' . $from_email . '>';
    $subject = "=?UTF-8?B?" . base64_encode($subject) . "?=";
    $headers = 'From: ' . $from . "\r\n" . 'Date: ' . gmdate('r') . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-transfer-encoding: 8bit' . "\r\n" . 'Content-type: text/plain; charset=utf-8' . "\r\n" . 'X-Mailer: PunBB Mailer';
    // If we specified a reply-to email, we deal with it here
    if (!empty($reply_to_email)) {
        $reply_to = "=?UTF-8?B?" . base64_encode($reply_to_name) . "?=" . ' <' . $reply_to_email . '>';
        $headers .= "\r\n" . 'Reply-To: ' . $reply_to;
    }
    // Make sure all linebreaks are CRLF in message (and strip out any NULL bytes)
    $message = str_replace(array("\n", ""), array("\r\n", ''), forum_linebreaks($message));
    ($hook = get_hook('em_fn_forum_mail_pre_send')) ? eval($hook) : null;
    if ($forum_config['o_smtp_host'] != '') {
        smtp_mail($to, $subject, $message, $headers);
    } else {
        // Change the linebreaks used in the headers according to OS
        if (strtoupper(substr(PHP_OS, 0, 3)) == 'MAC') {
            $headers = str_replace("\r\n", "\r", $headers);
        } else {
            if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
                $headers = str_replace("\r\n", "\n", $headers);
            }
        }
        mail($to, $subject, $message, $headers);
    }
}
Exemple #6
0
function pun_mail($to, $subject, $message, $from = '')
{
    global $pun_config, $lang_common;
    // Default sender/return address
    if (!$from) {
        $from = '"' . str_replace('"', '', $pun_config['o_board_title'] . ' ' . $lang_common['Mailer']) . '" <' . $pun_config['o_webmaster_email'] . '>';
    }
    // Do a little spring cleaning
    $to = trim(preg_replace('#[\\n\\r]+#s', '', $to));
    $subject = trim(preg_replace('#[\\n\\r]+#s', '', $subject));
    $from = trim(preg_replace('#[\\n\\r:]+#s', '', $from));
    $headers = 'From: ' . $from . "\r\n" . 'Date: ' . date('r') . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-transfer-encoding: ' . $lang_common['mail_transfer_encoding'] . "\r\n" . 'Content-type: text/plain; charset=' . $lang_common['mail_encoding'] . "\r\n" . 'X-Mailer: PunBB Mailer';
    // 'mail_encoding'                 =>      'UTF-8',
    // 'mail_transfer_encoding'        =>      '7bit',
    // Make sure all linebreaks are CRLF in message (and strip out any NULL bytes)
    $message = str_replace(array("\n", ""), array("\r\n", ''), pun_linebreaks($message));
    //$message = str_replace("\n", "\r\n", pun_linebreaks($message)); // old
    if ($pun_config['o_smtp_host'] != '') {
        smtp_mail($to, $subject, $message, $headers);
    } else {
        // Change the linebreaks used in the headers according to OS
        if (strtoupper(substr(PHP_OS, 0, 3)) == 'MAC') {
            $headers = str_replace("\r\n", "\r", $headers);
        } else {
            if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
                $headers = str_replace("\r\n", "\n", $headers);
            }
        }
        //adding 5th parmeter to email function for correct returnpath
        if (ini_get('safe_mode')) {
            // Do it the safe mode way
            mail($to, $subject, $message, $headers);
        } else {
            // Do it the regular way
            mail($to, $subject, $message, $headers, "-r" . $pun_config['o_webmaster_email']);
        }
    }
}
    // send as HTML
    // 邮件主题
    $mail->Subject = $subject;
    // 邮件内容
    $mail->Body = '<html><head>' . '<meta http-equiv="Content-Language" content="zh-cn">' . '<meta http-equiv="Content-Type" content="text/html; charset=GB2312"> ' . '</head>' . '<body>' . 'I love php' . '</body>' . '</html>';
    $mail->AltBody = "text/html";
    if (!$mail->Send()) {
        echo "邮件发送有误 <p>";
        echo "邮件错误信息: " . $mail->ErrorInfo;
        exit;
    } else {
        echo "{$user_name} 邮件发送成功!<br />";
    }
}
// 参数说明(发送到, 邮件主题, 邮件内容, 附加信息, 用户名)
smtp_mail("*****@*****.**", "欢迎使用phpmailer!", null, "yourdomain.com", "夏了夏天");
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
//date_default_timezone_set('Etc/UTC');
//
////require '../PHPMailerAutoload.php';
//
////Create a new PHPMailer instance
//$mail = new PHPMailer();
//$mail->CharSet = 'utf-8';
////Tell PHPMailer to use SMTP
//$mail->isSMTP();
////Enable SMTP debugging
//// 0 = off (for production use)
//// 1 = client messages
//// 2 = client and server messages
                    $message .= "Name: " . $creid[0]['Task_Name'] . "\r\n<br />";
                    $message .= $r['Task_Description'] . "\r\n<br />";
                    $tsk = $slave->select("SELECT * FROM Task_Logs WHERE Task_ID=" . $data['Task_ID']);
                    if ($tsk) {
                        foreach ($tsk as $t) {
                            $message .= $t['Public_Note'] . "\r\n<br />";
                        }
                    }
                    if (valid_email($requester[0]['Email'])) {
                        $ftemail = $requester[0]['Email'];
                    } else {
                        $ftemail = $noreply_email;
                    }
                    //print_r($r);
                    //print_r($requester);
                    smtp_mail("", "", $r['Email'], $ftemail, display_name($requester[0]['First_Name'], $requester[0]['Last_Name']), $ftemail, $subject, $message);
                }
            }
        }
    }
} elseif ($_POST['acknowledge']) {
    foreach ($_POST['acknowledge'] as $tid => $ack) {
        $data['User_ID'] = $_SESSION['user_id'];
        $data['Acknowledged'] = date("Y-m-d H:i:s");
        $data['Accepted'] = '1';
        $data['Task_ID'] = $tid;
        $data['Progress'] = $_POST['progress'][$tid];
        $insert = $db->insert("Task_Acknowledgement", $data);
    }
} elseif ($_POST['task_id']) {
    $data['User_ID'] = $_SESSION['user_id'];
Exemple #9
0
function pun_mail($to, $subject, $message, $reply_to_email = '', $reply_to_name = '')
{
    global $pun_config, $lang;
    // Default sender/return address
    $from_name = $lang->t('Mailer', $pun_config['o_board_title']);
    $from_email = $pun_config['o_webmaster_email'];
    // Do a little spring cleaning
    $to = pun_trim(preg_replace('%[\\n\\r]+%s', '', $to));
    $subject = pun_trim(preg_replace('%[\\n\\r]+%s', '', $subject));
    $from_email = pun_trim(preg_replace('%[\\n\\r:]+%s', '', $from_email));
    $from_name = pun_trim(preg_replace('%[\\n\\r:]+%s', '', str_replace('"', '', $from_name)));
    $reply_to_email = pun_trim(preg_replace('%[\\n\\r:]+%s', '', $reply_to_email));
    $reply_to_name = pun_trim(preg_replace('%[\\n\\r:]+%s', '', str_replace('"', '', $reply_to_name)));
    // Set up some headers to take advantage of UTF-8
    $from = '"' . encode_mail_text($from_name) . '" <' . $from_email . '>';
    $subject = encode_mail_text($subject);
    $headers = 'From: ' . $from . "\r\n" . 'Date: ' . gmdate('r') . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-transfer-encoding: 8bit' . "\r\n" . 'Content-type: text/plain; charset=utf-8' . "\r\n" . 'X-Mailer: FluxBB Mailer';
    // If we specified a reply-to email, we deal with it here
    if (!empty($reply_to_email)) {
        $reply_to = '"' . encode_mail_text($reply_to_name) . '" <' . $reply_to_email . '>';
        $headers .= "\r\n" . 'Reply-To: ' . $reply_to;
    }
    // Make sure all linebreaks are LF in message (and strip out any NULL bytes)
    $message = str_replace("", '', pun_linebreaks($message));
    if ($pun_config['o_smtp_host'] != '') {
        // Headers should be \r\n
        // Message should be ??
        $message = str_replace("\n", "\r\n", $message);
        smtp_mail($to, $subject, $message, $headers);
    } else {
        // Headers should be \r\n
        // Message should be \n
        mail($to, $subject, $message, $headers);
    }
}
Exemple #10
0
function ReduceMailQueue($number = false, $override_limit = false, $force_send = false)
{
    global $modSettings, $smcFunc, $sourcedir;
    // Are we intending another script to be sending out the queue?
    if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) {
        return false;
    }
    // By default send 5 at once.
    if (!$number) {
        $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity'];
    }
    // If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us.
    if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) {
        return false;
    }
    // By default move the next sending on by 10 seconds, and require an affected row.
    if (!$override_limit) {
        $delay = !empty($modSettings['mail_queue_delay']) ? $modSettings['mail_queue_delay'] : (!empty($modSettings['mail_limit']) && $modSettings['mail_limit'] < 5 ? 10 : 5);
        smf_db_query('
			UPDATE {db_prefix}settings
			SET value = {string:next_mail_send}
			WHERE variable = {string:mail_next_send}
				AND value = {string:last_send}', array('next_mail_send' => time() + $delay, 'mail_next_send' => 'mail_next_send', 'last_send' => $modSettings['mail_next_send']));
        if (smf_db_affected_rows() == 0) {
            return false;
        }
        $modSettings['mail_next_send'] = time() + $delay;
    }
    // If we're not overriding how many are we allow to send?
    if (!$override_limit && !empty($modSettings['mail_limit'])) {
        list($mt, $mn) = @explode('|', $modSettings['mail_recent']);
        // Nothing worth noting...
        if (empty($mn) || $mt < time() - 60) {
            $mt = time();
            $mn = $number;
        } elseif ($mn < $modSettings['mail_limit']) {
            $mn += $number;
        } else {
            return false;
        }
        // Reflect that we're about to send some, do it now to be safe.
        updateSettings(array('mail_recent' => $mt . '|' . $mn));
    }
    // Now we know how many we're sending, let's send them.
    $request = smf_db_query('
		SELECT /*!40001 SQL_NO_CACHE */ id_mail, recipient, body, subject, headers, send_html
		FROM {db_prefix}mail_queue
		ORDER BY priority ASC, id_mail ASC
		LIMIT ' . $number, array());
    $ids = array();
    $emails = array();
    while ($row = mysql_fetch_assoc($request)) {
        // We want to delete these from the database ASAP, so just get the data and go.
        $ids[] = $row['id_mail'];
        $emails[] = array('to' => $row['recipient'], 'body' => $row['body'], 'subject' => $row['subject'], 'headers' => $row['headers'], 'send_html' => $row['send_html']);
    }
    mysql_free_result($request);
    // Delete, delete, delete!!!
    if (!empty($ids)) {
        smf_db_query('
			DELETE FROM {db_prefix}mail_queue
			WHERE id_mail IN ({array_int:mail_list})', array('mail_list' => $ids));
    }
    // Don't believe we have any left?
    if (count($ids) < $number) {
        // Only update the setting if no-one else has beaten us to it.
        smf_db_query('
			UPDATE {db_prefix}settings
			SET value = {string:no_send}
			WHERE variable = {string:mail_next_send}
				AND value = {string:last_mail_send}', array('no_send' => '0', 'mail_next_send' => 'mail_next_send', 'last_mail_send' => $modSettings['mail_next_send']));
    }
    if (empty($ids)) {
        return false;
    }
    if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') {
        require_once $sourcedir . '/lib/Subs-Post.php';
    }
    // Send each email, yea!
    $failed_emails = array();
    foreach ($emails as $key => $email) {
        if (empty($modSettings['mail_type']) || $modSettings['smtp_host'] == '') {
            $email['subject'] = strtr($email['subject'], array("\r" => '', "\n" => ''));
            if (!empty($modSettings['mail_strip_carriage'])) {
                $email['body'] = strtr($email['body'], array("\r" => ''));
                $email['headers'] = strtr($email['headers'], array("\r" => ''));
            }
            // No point logging a specific error here, as we have no language. PHP error is helpful anyway...
            $result = mail(strtr($email['to'], array("\r" => '', "\n" => '')), $email['subject'], $email['body'], $email['headers']);
            // Try to stop a timeout, this would be bad...
            @set_time_limit(300);
            if (function_exists('apache_reset_timeout')) {
                @apache_reset_timeout();
            }
        } else {
            $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['send_html'] ? $email['headers'] : 'Mime-Version: 1.0' . "\r\n" . $email['headers']);
        }
        // Hopefully it sent?
        if (!$result) {
            $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html']);
        }
    }
    // Any emails that didn't send?
    if (!empty($failed_emails)) {
        // Update the failed attempts check.
        smf_db_insert('replace', '{db_prefix}settings', array('variable' => 'string', 'value' => 'string'), array('mail_failed_attempts', empty($modSettings['mail_failed_attempts']) ? 1 : ++$modSettings['mail_failed_attempts']), array('variable'));
        // If we have failed to many times, tell mail to wait a bit and try again.
        if ($modSettings['mail_failed_attempts'] > 5) {
            smf_db_query('
				UPDATE {db_prefix}settings
				SET value = {string:mail_next_send}
				WHERE variable = {string:next_mail_send}
					AND value = {string:last_send}', array('next_mail_send' => time() + 60, 'mail_next_send' => 'mail_next_send', 'last_send' => $modSettings['mail_next_send']));
        }
        // Add our email back to the queue, manually.
        smf_db_insert('insert', '{db_prefix}mail_queue', array('recipient' => 'string', 'body' => 'string', 'subject' => 'string', 'headers' => 'string', 'send_html' => 'string'), $failed_emails, array('id_mail'));
        return false;
    } elseif (!empty($modSettings['mail_failed_attempts'])) {
        smf_db_query('
			UPDATE {db_prefix}settings
			SET value = {string:zero}
			WHERE variable = {string:mail_failed_attempts}', array('zero' => '0', 'mail_failed_attempts' => 'mail_failed_attempts'));
    }
    // Had something to send...
    return true;
}
Exemple #11
0
if ($act == "send_code") {
    if (empty($email) || !preg_match("/^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]w+)*\$/", $email)) {
        exit("邮箱格式错误");
    }
    $sql = "select * from " . table('members') . " where email = '{$email}' LIMIT 1";
    $userinfo = $db->getone($sql);
    if ($userinfo && $userinfo['uid'] != $_SESSION['uid']) {
        exit("邮箱已经存在!请填写其他邮箱");
    } elseif (!empty($userinfo['email']) && $userinfo['email_audit'] == "1" && $userinfo['email'] == $email) {
        exit("你的邮箱 {$email} 已经通过验证!");
    } else {
        if ($_SESSION['sendemail_time'] && time() - $_SESSION['sendemail_time'] < 10) {
            exit("请60秒后再进行验证!");
        }
        $rand = mt_rand(100000, 999999);
        if (smtp_mail($email, "{$_CFG['site_name']}邮件认证", "{$QISHI['site_name']}提醒您:<br>您正在进行邮箱验证,验证码为:<strong>{$rand}</strong>")) {
            $_SESSION['verify_email'] = $email;
            $_SESSION['email_rand'] = $rand;
            $_SESSION['sendemail_time'] = time();
            exit("success");
        } else {
            exit("邮箱配置出错,请联系网站管理员");
        }
    }
} elseif ($act == "verify_code") {
    $verifycode = trim($_POST['verifycode']);
    if (empty($verifycode) || empty($_SESSION['email_rand']) || $verifycode != $_SESSION['email_rand']) {
        exit("验证码错误");
    } else {
        $uid = intval($_SESSION['uid']);
        if (empty($uid)) {
Exemple #12
0
    // 发件人邮箱
    $mail->FromName = "PHPMailer";
    // 发件人
    $mail->CharSet = "utf-8";
    // 这里指定字符集!
    $mail->Encoding = "base64";
    $mail->AddAddress($sendto_email, "王庭蛟");
    // 收件人邮箱和姓名
    $mail->AddReplyTo("*****@*****.**", "yourdomain.com");
    //$mail->WordWrap = 50; // set word wrap 换行字数
    //$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment 附件
    //$mail->AddAttachment("/tmp/image.jpg", "new.jpg");
    $mail->IsHTML(true);
    // send as HTML
    // 邮件主题
    $mail->Subject = $subject;
    // 邮件内容
    $mail->Body = "hello, this is an e-mail";
    $mail->AltBody = "text/html";
    if (!$mail->Send()) {
        echo "邮件发送有误 <p>";
        echo "邮件错误信息: " . $mail->ErrorInfo;
        exit;
    } else {
        echo "{$user_name} 邮件发送成功!<br />";
    }
}
// 参数说明(发送到, 邮件主题, 邮件内容, 附加信息, 用户名)
while ($i++ < 10) {
    smtp_mail("*****@*****.**", "欢迎使用phpmailer!", "NULL", "yourdomain.com", "327455748");
}
Exemple #13
0
        $htm .= '<div>
								没有填写工作经历
							</div>';
    }
    $htm .= '</div>';
    if ($resume_basic["specialty"]) {
        $htm .= '<div style="padding-bottom: 10px;">
				<p style="font-size: 16px;font-weight: 700;">自我描述</p>
				<p>' . $resume_basic["specialty"] . '</p>
			</div>';
    }
    $htm .= '<div style="text-align: center;margin-top:20px">
				该简历来自<a href="' . $_CFG["site_domain"] . $_CFG["site_dir"] . '">' . $_CFG["site_name"] . '</a>
			</div>
		</div>';
    $rst = smtp_mail($_GET['email'], "{$resume_basic['fullname']}的简历", $htm);
    exit($rst);
} elseif ($act == "auto_refresh") {
    global $db;
    $id = $_GET['id'] ? intval($_GET['id']) : exit('ID丢失!');
    $user_points = get_user_points($_SESSION['uid']);
    $row = $db->getone("select * from " . table("jobs") . " where id={$id} and uid={$_SESSION['uid']} limit 1 ");
    /*  预约刷新  */
    if ($row['auto_refresh'] == 1) {
        $auto_refresh = $db->getone('select appointment_time,appointment_time_available,points,execute_time from ' . table("jobs_appointment_refresh") . " where jobs_id={$row['id']} limit 1");
        $row['auto_refresh_num_all'] = $auto_refresh['appointment_time'];
        $row['auto_refresh_num'] = $auto_refresh['appointment_time_available'];
        $row['points'] = $auto_refresh['points'];
        $row['points_day'] = $auto_refresh['points'] /= $auto_refresh['appointment_time'];
        $taday = date('Y-m-d');
        $is_taday = date("Y-m-d", $auto_refresh['execute_time']);
Exemple #14
0
 public function send_email($re_user_id, $re_user_email, $token, $active)
 {
     if ($re_user_id) {
         $re_user_id = md5($re_user_id);
         $subject = "使命青年团契确认函:请完成您的绑定";
         $user_name = $re_user_email;
         $msg = smtp_mail($re_user_email, $subject, "null", $re_user_id, $token, $user_name, $active);
         $this->response(array('status_code' => 200, 'message' => $msg, 'results' => $re_user_id));
         return;
     } else {
         $this->response(array('status_code' => 403, 'message' => '申请失败!请重试!'));
         return;
     }
 }
        if ($result['rows'] > 0) {
            mb_internal_encoding("UTF-8");
            $b_name = mb_encode_mimeheader($_POST['name'], 'UTF-8', 'Q');
            $b_subject = mb_encode_mimeheader($_POST['subject'], 'UTF-8', 'Q');
            $b_message = base64_encode($_POST['message']);
            $i = 0;
            while ($row = db_array($result['result'])) {
                $fTo = $row[0];
                $fHeaders = 'To: ' . $fTo . "\n";
                $fHeaders .= 'From: ' . $b_name . ' <' . $smtp_from_email . ">\n";
                $fHeaders .= 'Subject: ' . $b_subject . "\n";
                $fHeaders .= 'MIME-Version: 1.0' . "\n";
                $fHeaders .= 'Content-Type: text/plain; charset=UTF-8' . "\n";
                $fHeaders .= 'Content-Transfer-Encoding: base64' . "\n";
                $fHeaders .= $b_message;
                if (!smtp_mail($fTo, $smtp_from_email, $fHeaders)) {
                    flash_error(Config::lang_f('pSendmail_result_error', $fTo));
                } else {
                    flash_info(Config::lang_f('pSendmail_result_success', $fTo));
                }
            }
        }
        flash_info($PALANG['pBroadcast_success']);
        $smarty->assign('smarty_template', 'message');
        $smarty->display('index.tpl');
        //		echo '<p>'.$PALANG['pBroadcast_success'].'</p>';
    }
}
if ($_SERVER['REQUEST_METHOD'] == "GET" || $error == 1) {
    $smarty->assign('smtp_from_email', $smtp_from_email);
    $smarty->assign('error', $error);
Exemple #16
0
<?php

require dirname(__FILE__) . '/phpmailer/sendamail.php';
$msg = "<p>Name:" . $_POST['name'] . "</p>";
$msg .= "<p>Phone:" . $_POST['phone'] . "</p>";
$msg .= "<p>Age:" . $_POST['age'] . "</p>";
$msg .= "<p>Store:" . $_POST['store'] . "</p>";
$msg .= "<p>Email:" . $_POST['email'] . "</p>";
$msg .= "<p>Inquiry Projects:";
foreach ($_POST['inquiryprojects'] as $proj) {
    $msg .= $proj . " , ";
}
$msg .= "</p>";
$msg .= "<p>Source:";
foreach ($_POST['source'] as $src) {
    $msg .= $src . " , ";
}
$msg .= "</p>";
$msg .= "<p>Message:" . $_POST['msg'] . "</p>";
if ($_POST['subscription']) {
    $msg .= "<p>Subscription:Yes</p>";
}
if (smtp_mail("*****@*****.**", "Application Form ", $msg)) {
    echo "ok";
} else {
    echo "not ok!";
}
Exemple #17
0
/**
 * Called after executing the insert query (but before executing the ownership insert query).
 * 
 * @param $data
 * An associative array where the keys are field names and the values are the field data values that were inserted into the new record.
 * For this table, the array items are: 
 *     $data['firstname'], $data['lastname'], $data['email'], $data['phone'], $data['quantity'], $data['amount'], $data['mailinglist'], $data['remarks'], $data['transactiondate'], $data['seller'], $data['editingdate'], $data['editor']
 * Also includes the item $data['selectedID'] which stores the value of the primary key for the new record.
 * 
 * @param $memberInfo
 * An array containing logged member's info.
 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
 * 
 * @param $args
 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
 * 
 * @return
 * A boolean TRUE to perform the ownership insert operation or FALSE to cancel it.
 * Warning: if a FALSE is returned, the new record will have no ownership info.
 */
function trans_mrs2016_after_insert($data, $memberInfo, &$args)
{
    /* check if user add quantity value or not */
    if (!$data['quantity']) {
        return FALSE;
    }
    /* create child records in duck_mrs2016 table after inserting parent */
    $transaction_id = $data['transaction_id'];
    $creation_date = date("j-n-Y");
    $table_name = 'duck_mrs2016';
    /* member info */
    $member_id = $memberInfo['username'];
    $group_id = $memberInfo['groupID'];
    $date_updated = $date_added = time();
    /* array to insert all ducks in duck_mrs2016 table  */
    $sql_to_duck_mrs2016 = array();
    /* array to insert all ducks in membership_userrecords table  */
    $sql_to_membership_userrecords = array();
    /* get last inserted id in duck_mrs2016 table to calculate pks */
    $duck_id = sqlValue("select max(duck_id) from `duck_mrs2016`");
    /* list of all duck id's */
    $duck_ids = array();
    for ($i = 0; $i < $data['quantity']; $i++) {
        $sql_to_duck_mrs2016[] = "('{$transaction_id}','{$creation_date}')";
        /* check if there is value of duck_id */
        $pk = empty($duck_id) ? $i + 1 : $duck_id + $i + 1;
        $sql_to_membership_userrecords[] = "('{$table_name}','{$pk}','{$member_id}','{$date_added}','{$date_updated}','{$creation_date}')";
        $duck_ids[] = $pk;
    }
    sql("INSERT INTO `duck_mrs2016` (`transaction_id`,`creationdate`) VALUES " . implode(',', $sql_to_duck_mrs2016), $eo);
    sql("INSERT INTO `membership_userrecords`(`tableName`, `pkValue`, `memberID`, `dateAdded`, `dateUpdated`, `groupID`) VALUES " . implode(',', $sql_to_membership_userrecords), $eo);
    /* prepare list of duck IDs for email */
    $data['duck_ids'] = implode(' - ', $duck_ids);
    /* seller's full name */
    $data['seller_full_name'] = $memberInfo['custom'][0];
    /**
     * send an email when a new transaction is placed. 
     **/
    /* define associative array $mail_info to pass it to smtp_mail fn to send mail */
    $mail_info = array('cc' => $memberInfo['email'], 'to' => $data['email'], 'message' => loadView('email-to-buyer', $data), 'subject' => "Badeendrace 2016");
    /* send notification mail to seller and buyer */
    smtp_mail($mail_info);
    return TRUE;
}
    $mail->AddReplyTo("*****@*****.**", "cgsir.com");
    //$mail->WordWrap = 50; // set word wrap
    //$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
    //$mail->AddAttachment("/tmp/image.jpg", "new.jpg");
    $mail->IsHTML(true);
    // send as HTML
    // 邮件主题
    $mail->Subject = $subject;
    // 邮件内容
    $mail->Body = '
<html><head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=GB2312"></head>
<body>
欢迎来到<a href="http://www.cgsir.com">http://www.cgsir.com</a> <br /><br />
感谢您注册为本站会员!<br /><br />
</body>
</html>
';
    $mail->AltBody = "text/html";
    if (!$mail->Send()) {
        echo "邮件发送有误 <p>";
        echo "邮件错误信息: " . $mail->ErrorInfo;
        exit;
    } else {
        echo "{$user_name} 邮件发送成功!<br />";
    }
}
// 参数说明(发送到, 邮件主题, 邮件内容, 附加信息, 用户名)
smtp_mail('*****@*****.**', '欢迎来到cgsir.com!', 'NULL', 'cgsir.com', 'username');
Exemple #19
0
    $_CFG['user_unlogin_time'] = 30;
}
$last_time = strtotime("-" . $_CFG['user_unlogin_time'] . " day");
//查询会员最后一次登录时间情况
$result = $db->query("SELECT * FROM " . table('members') . " WHERE last_login_time < {$last_time} && remind_email_time < {$time} ");
while ($row = $db->fetch_array($result)) {
    $email = $row['email'];
    if ($row['email_audit'] == 0) {
        continue;
    }
    //企业
    if ($row['utype'] == '1') {
        smtp_mail($email, $_CFG['site_name'] . "向您发送了长时间未登录网站提醒", $html_resume, $mailconfig['smtpfrom'], $_CFG['site_name']);
    } elseif ($row['utype'] == '2') {
        continue;
        smtp_mail($email, $_CFG['site_name'] . "向您发送了长时间未登录网站提醒", $html_jobs, $mailconfig['smtpfrom'], $_CFG['site_name']);
    }
    //更新邮箱提醒时间
    $remind_email_time = strtotime("+" . $_CFG['user_unlogin_time'] . " day");
    $sql = "UPDATE " . table('members') . " SET remind_email_time = '{$remind_email_time}' WHERE uid='{$row['uid']}'  LIMIT 1";
    $db->query($sql);
}
//更新任务时间表
if ($crons['weekday'] >= 0) {
    $weekday = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
    $nextrun = strtotime("Next " . $weekday[$crons['weekday']]);
} elseif ($crons['day'] > 0) {
    $nextrun = strtotime('+1 months');
    $nextrun = mktime(0, 0, 0, date("m", $nextrun), $crons['day'], date("Y", $nextrun));
} else {
    $nextrun = time();
Exemple #20
0
    //$mail->WordWrap = 50; // set word wrap
    //$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
    //$mail->AddAttachment("/tmp/image.jpg", "new.jpg");
    $mail->IsHTML(true);
    // send as HTML
    // 邮件主题
    $mail->Subject = $subject;
    // 邮件内容
    $mail->Body = '
<html><head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
</head>
<body>
        欢迎来到<a href="http://www.cgsir.com">http://www.cgsir.com</a> <br /><br />
感谢您注册为本站会员!<br /><br />
</body>
</html>
';
    $mail->AltBody = "text/html";
    if (!$mail->Send()) {
        echo "邮件发送有误 <p>";
        echo "邮件错误信息: " . $mail->ErrorInfo;
        exit;
    } else {
        echo "{$user_name} 邮件发送成功!<br />";
    }
}
// 参数说明(发送到, 邮件主题, 邮件内容, 附加信息, 用户名)
smtp_mail('*****@*****.**', '欢迎来到cgsir.com!', 'NULL', 'cgsir.com', 'username');
Exemple #21
0
        $setsqlarr['m_type'] = 2;
        //发送失败
        $db->inserttable(table('mailqueue'), $setsqlarr);
        unset($setsqlarr);
        $link[0]['text'] = "返回上一页";
        $link[0]['href'] = "{$url}";
        adminmsg("发送失败,错误未知!", 0, $link);
    }
} elseif ($act == 'again_send') {
    $id = intval($_GET['id']);
    if (empty($id)) {
        adminmsg("请选择要发送的项目!", 1);
    }
    $result = $db->getone("SELECT * FROM " . table('mailqueue') . " WHERE  m_id = {$id} limit 1");
    $wheresql = " m_id={$id} ";
    if (smtp_mail($result['m_mail'], $result['m_subject'], $result['m_body'])) {
        $setsqlarr['m_sendtime'] = time();
        $setsqlarr['m_type'] = 1;
        //发送成功
        !$db->updatetable(table('mailqueue'), $setsqlarr, $wheresql);
        adminmsg('发送成功', 2);
    } else {
        $setsqlarr['m_sendtime'] = time();
        $setsqlarr['m_type'] = 2;
        !$db->updatetable(table('mailqueue'), $setsqlarr, $wheresql);
        adminmsg('发送失败', 0);
    }
} elseif ($act == 'del') {
    $id = $_POST['id'];
    if (empty($id)) {
        adminmsg("请选择项目!", 1);
Exemple #22
0
/**
 * Sends a group of emails from the mail queue.
 *
 * - Allows a batch of emails to be released every 5 to 10 seconds (based on per period limits)
 * - If batch size is not set, will determine a size such that it sends in 1/2 the period (buffer)
 *
 * @package Mail
 * @param int|false $batch_size = false the number to send each loop
 * @param boolean $override_limit = false bypassing our limit flaf
 * @param boolean $force_send = false
 * @return boolean
 */
function reduceMailQueue($batch_size = false, $override_limit = false, $force_send = false)
{
    global $modSettings, $context, $webmaster_email, $scripturl;
    // Do we have another script to send out the queue?
    if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) {
        return false;
    }
    // How many emails can we send each time we are called in a period
    if (!$batch_size) {
        // Batch size has been set in the ACP, use it
        if (!empty($modSettings['mail_batch_size'])) {
            $batch_size = $modSettings['mail_batch_size'];
        } elseif (empty($modSettings['mail_period_limit'])) {
            $batch_size = 5;
        } else {
            // Based on the number of times we will potentially be called each minute
            $delay = !empty($modSettings['mail_queue_delay']) ? $modSettings['mail_queue_delay'] : (!empty($modSettings['mail_period_limit']) && $modSettings['mail_period_limit'] <= 5 ? 10 : 5);
            $batch_size = ceil($modSettings['mail_period_limit'] / ceil(60 / $delay));
            $batch_size = $batch_size == 1 && $modSettings['mail_period_limit'] > 1 ? 2 : $batch_size;
        }
    }
    // If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us.
    if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) {
        return false;
    }
    // Prepare to send each email, and log that for future proof.
    require_once SUBSDIR . '/Maillist.subs.php';
    // Set the delay for the next sending
    if (!$override_limit) {
        // Update next send time for our mail queue, if there was something to update. Otherwise bail out :P
        $delay = updateNextSendTime();
        if ($delay === false) {
            return false;
        }
        $modSettings['mail_next_send'] = time() + $delay;
    }
    // If we're not overriding, do we have quota left in this mail period limit?
    if (!$override_limit && !empty($modSettings['mail_period_limit'])) {
        // See if we have quota left to send another batch_size this minute or if we have to wait
        list($mail_time, $mail_number) = isset($modSettings['mail_recent']) ? explode('|', $modSettings['mail_recent']) : array(0, 0);
        // Nothing worth noting...
        if (empty($mail_number) || $mail_time < time() - 60) {
            $mail_time = time();
            $mail_number = $batch_size;
        } elseif ($mail_number < $modSettings['mail_period_limit']) {
            // If this is likely one of the last cycles for this period, then send any remaining quota
            if ($mail_time - (time() - 60) < $delay * 2) {
                $batch_size = $modSettings['mail_period_limit'] - $mail_number;
            } elseif ($mail_number + $batch_size > $modSettings['mail_period_limit']) {
                $batch_size = $modSettings['mail_period_limit'] - $mail_number;
            }
            $mail_number += $batch_size;
        } else {
            return false;
        }
        // Reflect that we're about to send some, do it now to be safe.
        updateSettings(array('mail_recent' => $mail_time . '|' . $mail_number));
    }
    // Now we know how many we're sending, let's send them.
    list($ids, $emails) = emailsInfo($batch_size);
    // Delete, delete, delete!!!
    if (!empty($ids)) {
        deleteMailQueueItems($ids);
    }
    // Don't believe we have any left after this batch?
    if (count($ids) < $batch_size) {
        resetNextSendTime();
    }
    if (empty($ids)) {
        return false;
    }
    // We have some to send, lets send them!
    $sent = array();
    $failed_emails = array();
    // Use sendmail or SMTP
    $use_sendmail = empty($modSettings['mail_type']) || $modSettings['smtp_host'] == '';
    // Line breaks need to be \r\n only in windows or for SMTP.
    $line_break = !empty($context['server']['is_windows']) || !$use_sendmail ? "\r\n" : "\n";
    foreach ($emails as $key => $email) {
        // Use the right mail resource
        if ($use_sendmail) {
            $email['subject'] = strtr($email['subject'], array("\r" => '', "\n" => ''));
            if (!empty($modSettings['mail_strip_carriage'])) {
                $email['body'] = strtr($email['body'], array("\r" => ''));
                $email['headers'] = strtr($email['headers'], array("\r" => ''));
            }
            $need_break = substr($email['headers'], -1) === "\n" || substr($email['headers'], -1) === "\r" ? false : true;
            // Create our unique reply to email header if this message needs one
            $unq_id = '';
            $unq_head = '';
            if (!empty($modSettings['maillist_enabled']) && $email['message_id'] !== null && strpos($email['headers'], 'List-Id: <') !== false) {
                $unq_head = md5($scripturl . microtime() . rand()) . '-' . $email['message_id'];
                $encoded_unq_head = base64_encode($line_break . $line_break . '[' . $unq_head . ']' . $line_break);
                $unq_id = ($need_break ? $line_break : '') . 'Message-ID: <' . $unq_head . strstr(empty($modSettings['maillist_mail_from']) ? $webmaster_email : $modSettings['maillist_mail_from'], '@') . '>';
                $email['body_fail'] = $email['body'];
                $email['body'] = mail_insert_key($email['body'], $unq_head, $encoded_unq_head, $line_break);
            } elseif ($email['message_id'] !== null && empty($modSettings['mail_no_message_id'])) {
                $unq_id = ($need_break ? $line_break : '') . 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $email['message_id'] . strstr(empty($modSettings['maillist_mail_from']) ? $webmaster_email : $modSettings['maillist_mail_from'], '@') . '>';
            }
            // No point logging a specific error here, as we have no language. PHP error is helpful anyway...
            $result = mail(strtr($email['to'], array("\r" => '', "\n" => '')), $email['subject'], $email['body'], $email['headers'] . $unq_id);
            // If it sent, keep a record so we can save it in our allowed to reply log
            if (!empty($unq_head) && $result) {
                $sent[] = array($unq_head, time(), $email['to']);
            }
            // Track total emails sent
            if ($result && !empty($modSettings['trackStats'])) {
                trackStats(array('email' => '+'));
            }
            // Try to stop a timeout, this would be bad...
            @set_time_limit(300);
            if (function_exists('apache_reset_timeout')) {
                @apache_reset_timeout();
            }
        } else {
            $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['send_html'] ? $email['headers'] : 'Mime-Version: 1.0' . "\r\n" . $email['headers'], $email['priority'], $email['message_id']);
        }
        // Hopefully it sent?
        if (!$result) {
            $failed_emails[] = array(time(), $email['to'], $email['body_fail'], $email['subject'], $email['headers'], $email['send_html'], $email['priority'], $email['private'], $email['message_id']);
        }
    }
    // Clear out the stat cache.
    trackStats();
    // Log each of the sent emails.
    if (!empty($sent)) {
        log_email($sent);
    }
    // Any emails that didn't send?
    if (!empty($failed_emails)) {
        // If it failed, add it back to the queue
        updateFailedQueue($failed_emails);
        return false;
    } elseif (!empty($modSettings['mail_failed_attempts'])) {
        updateSuccessQueue();
    }
    // Had something to send...
    return true;
}
Exemple #23
0
function send_mail($address, $subject, $message)
{
    global $_config;
    switch ($_config['mail']['type']) {
        case 'kk_mail':
            return kk_mail($address, $subject, $message);
        case 'bcms':
            return bcms_mail($address, $subject, $message);
        case 'saemail':
            return saemail($address, $subject, $message);
        case 'mail':
            return mail($address, $subject, $message);
        case 'smtp':
            return smtp_mail($address, $subject, $message);
        default:
            return false;
    }
}
                } else {
                    $tMessage .= ")</br />";
                }
            }
            $tQuota = $CONF['maxquota'];
            if ($fMail == "on") {
                $fTo = $fUsername;
                $fFrom = $SESSID_USERNAME;
                $fHeaders = "To: " . $fTo . "\n";
                $fHeaders .= "From: " . $fFrom . "\n";
                $fHeaders .= "Subject: " . encode_header($PALANG['pSendmail_subject_text']) . "\n";
                $fHeaders .= "MIME-Version: 1.0\n";
                $fHeaders .= "Content-Type: text/plain; charset=utf-8\n";
                $fHeaders .= "Content-Transfer-Encoding: 8bit\n";
                $fHeaders .= $CONF['welcome_text'];
                if (!smtp_mail($fTo, $fFrom, $fHeaders)) {
                    $tMessage .= "<br />" . $PALANG['pSendmail_result_error'] . "<br />";
                } else {
                    $tMessage .= "<br />" . $PALANG['pSendmail_result_success'] . "<br />";
                }
            }
            if (create_mailbox_subfolders($fUsername, $fPassword)) {
                $tMessage = $PALANG['pCreate_mailbox_result_success'] . "<br />({$fUsername}";
            } else {
                $tMessage = $PALANG['pCreate_mailbox_result_succes_nosubfolders'] . "<br />({$fUsername}";
            }
        }
    }
}
include "templates/header.php";
include "templates/menu.php";
Exemple #25
0
function sendmail($to, $subject, $message, $from = null, $message_id = null, $send_html = false, $priority = 1, $hotmail_fix = null)
{
    global $webmaster_email, $context, $modSettings, $txt, $scripturl;
    // Use sendmail if it's set or if no SMTP server is set.
    $use_sendmail = empty($modSettings['mail_type']) || $modSettings['smtp_host'] == '';
    // Line breaks need to be \r\n only in windows or for SMTP.
    $line_break = $context['server']['is_windows'] || !$use_sendmail ? "\r\n" : "\n";
    // So far so good.
    $mail_result = true;
    // If the recipient list isn't an array, make it one.
    $to_array = is_array($to) ? $to : array($to);
    // Sadly Hotmail & Yahoomail don't support character sets properly.
    if ($hotmail_fix === null) {
        $hotmail_to = array();
        foreach ($to_array as $i => $to_address) {
            if (preg_match('~@(yahoo|hotmail)\\.[a-zA-Z\\.]{2,6}$~i', $to_address) === 1) {
                $hotmail_to[] = $to_address;
                $to_array = array_diff($to_array, array($to_address));
            }
        }
        // Call this function recursively for the hotmail addresses.
        if (!empty($hotmail_to)) {
            $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true);
        }
        // The remaining addresses no longer need the fix.
        $hotmail_fix = false;
        // No other addresses left? Return instantly.
        if (empty($to_array)) {
            return $mail_result;
        }
    }
    // Get rid of slashes and entities.
    $subject = un_htmlspecialchars(stripslashes($subject));
    // Make the message use the proper line breaks.
    $message = str_replace(array("\r", "\n"), array('', $line_break), stripslashes($message));
    // Make sure hotmail mails are sent as HTML so that HTML entities work.
    if ($hotmail_fix && !$send_html) {
        $send_html = true;
        $message = strtr($message, array($line_break => '<br />' . $line_break));
        $message = preg_replace('~(' . preg_quote($scripturl, '~') . '([?/][\\w\\-_%\\.,\\?&;=#]+)?)~', '<a href="$1">$1</a>', $message);
    }
    list(, $from_name) = mimespecialchars(addcslashes($from !== null ? $from : $context['forum_name'], '<>()\'\\"'), true, $hotmail_fix, $line_break);
    list(, $subject) = mimespecialchars($subject, true, $hotmail_fix, $line_break);
    // Construct the mail headers...
    $headers = 'From: "' . $from_name . '" <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>' . $line_break;
    $headers .= $from !== null ? 'Reply-To: <' . $from . '>' . $line_break : '';
    $headers .= 'Return-Path: ' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . $line_break;
    $headers .= 'Date: ' . gmdate('D, d M Y H:i:s') . ' -0000' . $line_break;
    if ($message_id !== null && empty($modSettings['mail_no_message_id'])) {
        $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break;
    }
    $headers .= 'X-Mailer: SMF' . $line_break;
    // pass this to the integration before we start modifying the output -- it'll make it easier later
    if (isset($modSettings['integrate_outgoing_email']) && function_exists($modSettings['integrate_outgoing_email'])) {
        if ($modSettings['integrate_outgoing_email']($subject, $message, $headers) === false) {
            return false;
        }
    }
    // Save the original message...
    $orig_message = $message;
    // The mime boundary separates the different alternative versions.
    $mime_boundary = 'SMF-' . md5($message . time());
    // Sending HTML?  Let's plop in some basic stuff, then.
    if ($send_html) {
        // This should send a text message with MIME multipart/alternative stuff.
        $headers .= 'Mime-Version: 1.0' . $line_break;
        $headers .= 'Content-Type: multipart/alternative; boundary="' . $mime_boundary . '"' . $line_break;
        $headers .= 'Content-Transfer-Encoding: 7bit' . $line_break;
        $no_html_message = un_htmlspecialchars(strip_tags(strtr($orig_message, array('</title>' => $line_break))));
        // But, then, dump it and use a plain one for dinosaur clients.
        list(, $plain_message) = mimespecialchars($no_html_message, false, true, $line_break);
        $message = $plain_message . $line_break . '--' . $mime_boundary . $line_break;
        // This is the plain text version.  Even if no one sees it, we need it for spam checkers.
        list($charset, $plain_charset_message, $encoding) = mimespecialchars($no_html_message, false, false, $line_break);
        $message .= 'Content-Type: text/plain; charset=' . $charset . $line_break;
        $message .= 'Content-Transfer-Encoding: ' . $encoding . $line_break . $line_break;
        $message .= $plain_charset_message . $line_break . '--' . $mime_boundary . $line_break;
        // This is the actual HTML message, prim and proper.  If we wanted images, they could be inlined here (with multipart/related, etc.)
        list($charset, $html_message, $encoding) = mimespecialchars($orig_message, false, $hotmail_fix, $line_break);
        $message .= 'Content-Type: text/html; charset=' . $charset . $line_break;
        $message .= 'Content-Transfer-Encoding: ' . ($encoding == '' ? '7bit' : $encoding) . $line_break . $line_break;
        $message .= $html_message . $line_break . '--' . $mime_boundary . '--';
    } else {
        // Using mime, as it allows to send a plain unencoded alternative.
        $headers .= 'Mime-Version: 1.0' . $line_break;
        $headers .= 'Content-Type: multipart/alternative; boundary="' . $mime_boundary . '"' . $line_break;
        $headers .= 'Content-Transfer-Encoding: 7bit' . $line_break;
        // Send a plain message first, for the older web clients.
        list(, $plain_message) = mimespecialchars($orig_message, false, true, $line_break);
        $message = $plain_message . $line_break . '--' . $mime_boundary . $line_break;
        // Now add an encoded message using the forum's character set.
        list($charset, $encoded_message, $encoding) = mimespecialchars($orig_message, false, false, $line_break);
        $message .= 'Content-Type: text/plain; charset=' . $charset . $line_break;
        $message .= 'Content-Transfer-Encoding: ' . $encoding . $line_break . $line_break;
        $message .= $encoded_message . $line_break . '--' . $mime_boundary . '--';
    }
    // SMTP or sendmail?
    if ($use_sendmail) {
        $subject = strtr($subject, array("\r" => '', "\n" => ''));
        if (!empty($modSettings['mail_strip_carriage'])) {
            $message = strtr($message, array("\r" => ''));
            $headers = strtr($headers, array("\r" => ''));
        }
        foreach ($to_array as $to) {
            if (!mail(strtr($to, array("\r" => '', "\n" => '')), $subject, $message, $headers)) {
                log_error(sprintf($txt['mail_send_unable'], $to));
                $mail_result = false;
            }
            // Wait, wait, I'm still sending here!
            @set_time_limit(300);
            if (function_exists('apache_reset_timeout')) {
                apache_reset_timeout();
            }
        }
    } else {
        $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $send_html ? $headers : "Mime-Version: 1.0" . $line_break . $headers);
    }
    // Everything go smoothly?
    return $mail_result;
}
Exemple #26
0
    }
    $setsqlarr['resume_id'] = intval($_POST['resume_id']) ? intval($_POST['resume_id']) : showmsg('请选择发送简历!', 1);
    $setsqlarr['resume_title'] = trim($_POST['resume_title']) ? trim($_POST['resume_title']) : showmsg('请选择发送简历!', 1);
    $setsqlarr['email'] = trim($_POST['email']) ? trim($_POST['email']) : showmsg('请填写邮箱地址!', 1);
    $setsqlarr['companyname'] = trim($_POST['companyname']) ? trim($_POST['companyname']) : showmsg('请填写企业名称!', 1);
    check_word($_CFG['filter'], $_POST['companyname']) ? showmsg($_CFG['filter_tips'], 0) : '';
    $setsqlarr['jobs_name'] = trim($_POST['jobs_name']) ? trim($_POST['jobs_name']) : showmsg('请填写职位名称!', 1);
    check_word($_CFG['filter'], $_POST['jobs_name']) ? showmsg($_CFG['filter_tips'], 0) : '';
    //验证邮箱是否正确
    $resume_tpl = get_outward_resumes_tpl($_SESSION['uid'], $setsqlarr['resume_id']);
    $email = explode(';', $setsqlarr['email']);
    foreach ($email as $key => $value) {
        if (!preg_match("/^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$/", $value)) {
            showmsg('请正确填写邮箱地址!', 1);
        }
        $rst = smtp_mail($value, $setsqlarr['resume_title'], $resume_tpl);
        if ($rst != '1') {
            showmsg('此邮箱:{$value}发送失败!', 0);
        }
    }
    $setsqlarr['uid'] = intval($_SESSION['uid']);
    $setsqlarr['addtime'] = time();
    //添加简历外发记录
    $oid = $db->inserttable(table('resume_outward'), $setsqlarr, true);
    if (empty($oid)) {
        showmsg("添加失败!", 0);
    } else {
        showmsg("添加成功!", 2);
    }
} elseif ($act == 'resume_import') {
    if ($_SESSION['cookie_name']) {
    $smarty->assign('verify_getpwd', $captcha['verify_getpwd']);
    $smarty->assign('sms', get_cache('sms_config'));
    $smarty->assign('step', "1");
    $smarty->display('wap/wap-alter-password.html');
} elseif ($act == 'get_pass') {
    $captcha = get_cache('captcha');
    $postcaptcha = trim($_POST['postcaptcha']);
    $postusername = trim($_POST['username']) ? trim($_POST['username']) : exit('请填写用户名');
    if (empty($_POST['email']) || !preg_match("/^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$/", $_POST['email'])) {
        echo '电子邮箱格式错误!';
    }
    require_once QISHI_ROOT_PATH . 'include/fun_user.php';
    $userinfo = get_user_inusername($postusername);
    if (empty($userinfo) || $userinfo['email'] != $_POST['email']) {
        echo '用户名或注册邮箱填写错误';
    } else {
        $mailconfig = get_cache('mailconfig');
        $arr['username'] = $userinfo['username'];
        $arr['password'] = rand(100000, 999999) . randstr();
        if (smtp_mail($userinfo['email'], "找回密码", "您的新密码为:" . $arr['password'])) {
            $md5password = md5(md5($arr['password']) . $userinfo['pwd_hash'] . $QS_pwdhash);
            if (!$db->query("UPDATE " . table('members') . " SET password = '******'  WHERE uid='{$userinfo['uid']}'")) {
                echo '密码修改失败';
            }
            echo '密码修改成功请查看您的邮箱';
        } else {
            echo '邮件发送失败,请联系网站管理员';
        }
    }
}
unset($smarty);
Exemple #28
0
 $senderr = intval($_GET['senderr']);
 $intervaltime = intval($_GET['intervaltime']);
 $tempdir = QISHI_ROOT_PATH . "temp/send.txt";
 $content = file_get_contents($tempdir);
 $idarr = unserialize($content);
 $totalid = count($idarr);
 if (empty($idarr)) {
     $link[0]['text'] = "返回邮件列队";
     $link[0]['href'] = '?act=list';
     adminmsg("任务执行完毕!", 2, $link);
 } else {
     $m_id = array_shift($idarr);
     @file_put_contents($tempdir, serialize($idarr));
     $mail = $db->getone("select * from " . table('mailqueue') . " where m_id = '" . intval($m_id) . "' LIMIT 1");
     $mailconfig = get_cache('mailconfig');
     if (!smtp_mail($mail['m_mail'], $mail['m_subject'], $mail['m_body'])) {
         $db->query("update  " . table('mailqueue') . " SET m_type='2'  WHERE m_id = '" . intval($m_id) . "'  LIMIT 1");
         if ($senderr == "2") {
             $link[0]['text'] = "返回邮件列队";
             $link[0]['href'] = '?act=list';
             adminmsg('邮件发送发生错误!' . $senderr, 0, $link);
         } else {
             $link[0]['text'] = "发送下一封";
             $link[0]['href'] = "?act=send&senderr={$senderr}&intervaltime={$intervaltime}";
             adminmsg("发生错误,准备发送下一封,剩余任务总数:" . ($totalid - 1), 0, $link, true, $intervaltime);
         }
     } else {
         $db->query("update  " . table('mailqueue') . " SET m_type='1',m_sendtime='" . time() . "'  WHERE m_id = '" . intval($m_id) . "'  LIMIT 1");
         $link[0]['text'] = "发送下一封";
         $link[0]['href'] = "?act=send&senderr={$senderr}&intervaltime={$intervaltime}";
         adminmsg("发送成功,准备发送下一封,剩余任务总数:" . ($totalid - 1), 2, $link, true, $intervaltime);
 private function send_welcome_mail()
 {
     $fTo = $this->id;
     $fFrom = smtp_get_admin_email();
     if (empty($fFrom) || $fFrom == 'CLI') {
         $fFrom = $this->id;
     }
     $fSubject = Config::lang('pSendmail_subject_text');
     $fBody = Config::read('welcome_text');
     if (!smtp_mail($fTo, $fFrom, $fSubject, $fBody)) {
         $this->errormsg[] = Config::lang_f('pSendmail_result_error', $this->id);
         return false;
     }
     return true;
 }
Exemple #30
0
        $url = "?act=send";
    }
    $smarty->assign('url', $url);
    $smarty->display('mail/admin_mail_send.htm');
} elseif ($act == 'email_send') {
    $email = trim($_POST['email']);
    $subject = trim($_POST['subject']);
    $body = trim($_POST['body']);
    $url = trim($_REQUEST['url']);
    if (empty($subject) || empty($body)) {
        crmmsg('标题和内容不能为空!', 0);
    }
    if (empty($email)) {
        crmmsg('收件人不能为空!', 0);
    }
    if (!preg_match("/^[\\w\\-\\.]+@[\\w\\-\\.]+(\\.\\w+)+\$/", $email)) {
        $link[0]['text'] = "返回上一页";
        $link[0]['href'] = "{$url}";
        crmmsg("发送失败!<strong>{$mobile}</strong> 格式不正确", 1, $link);
    } else {
        if (smtp_mail($email, $subject, $body)) {
            $link[0]['text'] = "返回上一页";
            $link[0]['href'] = "{$url}";
            crmmsg("发送成功!", 2, $link);
        } else {
            $link[0]['text'] = "返回上一页";
            $link[0]['href'] = "{$url}";
            crmmsg("发送失败,错误未知!", 2, $link);
        }
    }
}