function SEND_MAIL() { $main = new maincf_multi($_POST["hostname"]); $ipaddr = $main->ip_addr; include_once dirname(__FILE__) . "/ressources/smtp/smtp.php"; $Parms["host"] = $ipaddr; $Parms["DonotResolvMX"] = true; $smtp = new smtp($Parms); $smtp->bindto = $_POST["TESTS-BIND"]; $smtp->from = $_POST["TESTS-FROM"]; $smtp->recipients = $_POST["TESTS-TO"]; $f[] = "Return-Path: <{$_POST["TESTS-FROM"]}>"; $f[] = "Subject: {$_POST["TESTS-SUB"]}"; $f[] = "From: {$_POST["TESTS-FROM"]}"; $f[] = "Sender: {$_POST["TESTS-FROM"]}"; $f[] = "Reply-To: {$_POST["TESTS-FROM"]}"; $f[] = "X-Sender: {$_POST["TESTS-FROM"]}"; $f[] = "Envelope-To: {$_POST["TESTS-TO"]}"; $smtp->headers = @implode("\n", $f); $smtp->body = $_POST["TESTS-BOD"]; if (!$smtp->connect()) { echo "Instance {$_POST["hostname"]}\nIP: {$ipaddr}:25\n"; echo @implode("\n", $smtp->errors); return; } if (!$smtp->send()) { echo @implode("\n", $smtp->errors); return; } echo @implode("\n", $smtp->errors); }
function send_mail($to, $subject, $body) { include FCPATH . APPPATH . 'libraries/smtp.php'; $smtpinfo = array(); $smtpinfo["host"] = "smtp.qq.com"; $smtpinfo["username"] = "******"; $smtpinfo["password"] = "******"; $smtpinfo["port"] = "25"; $from = $smtpinfo['username']; $subject = '=?utf-8?B?' . base64_encode($subject) . '?='; $smtpMail = new smtp($smtpinfo['host'], $smtpinfo['username'], $smtpinfo['password'], $smtpinfo['port']); $smtpMail->setHeader('Content-Transfer-Encoding', '8bit'); $smtpMail->setFrom($from, '=?utf-8?B?' . base64_encode("酷Live网") . '?='); $smtpMail->addTo($to); $smtpMail->setSubject($subject); $smtpMail->setBody($body); @$smtpMail->send(); }
function archive_process_smtpsrv($file, $realmailfrom, $realmailto) { $MailArchiverToSMTP = $GLOBALS["MailArchiverToSMTP"]; $MailArchiverSMTP = $GLOBALS["MailArchiverSMTP"]; $MailArchiverSMTPINcoming = $GLOBALS["MailArchiverSMTPINcoming"]; $MailArchiverSMTP_port = 25; $SMTPSERV = true; $realmailto = trim(strtolower($realmailto)); if ($MailArchiverSMTP == null) { $SMTPSERV = false; } if ($MailArchiverSMTP == "localhost") { $SMTPSERV = false; } if ($MailArchiverSMTP == "127.0.0.1") { $SMTPSERV = false; } if (!$SMTPSERV) { events("Not from=<{$realmailfrom}> to=<{$realmailto}> bad remote SMTP server `{$MailArchiverSMTP}`", __LINE__); return true; } if (preg_match("#^(.+?)@(.+)#", $realmailto, $re)) { $DomainTo = trim($re[1]); } if (!isset($GLOBALS["INBOUND_SMTP"])) { $f = explode("\n", @file_get_contents("/etc/postfix/mydestination")); while (list($num, $line) = each($f)) { if (preg_match("#^(.+?)\\s+#", $line, $re)) { $GLOBALS["INBOUND_SMTP"][trim(strtolower($re[1]))] = true; } } $f = explode("\n", @file_get_contents("/etc/postfix/relay_domains")); while (list($num, $line) = each($f)) { if (preg_match("#^(.+?)\\s+#", $line, $re)) { $GLOBALS["INBOUND_SMTP"][trim(strtolower($re[1]))] = true; } } $f = explode("\n", @file_get_contents("/etc/postfix/virtual")); while (list($num, $line) = each($f)) { if (preg_match("#^(.+?)\\s+#", $line, $re)) { $GLOBALS["INBOUND_SMTP"][trim(strtolower($re[1]))] = true; } } } $ISINBOUND = false; if (isset($GLOBALS["INBOUND_SMTP"][$realmailto])) { $ISINBOUND = true; } if (isset($GLOBALS["INBOUND_SMTP"][$DomainTo])) { $ISINBOUND = true; } if ($MailArchiverSMTPINcoming == 1) { if (!$ISINBOUND) { events("Not from=<{$realmailfrom}> to=<{$realmailto}> not an inbound message", __LINE__); return true; } } if (preg_match("#^(.+?):([0-9]+)#", $MailArchiverSMTP, $re)) { $MailArchiverSMTP = $re[1]; $MailArchiverSMTP_port = $re[2]; } $basename = basename($file); $smtp = new smtp(); $params["host"] = $MailArchiverSMTP; $params["helo"] = $GLOBALS["MYHOSTNAME"]; $params["port"] = $MailArchiverSMTP_port; //$params["bindto"]="127.0.0.1"; if (!$smtp->connect($params)) { events("[{$basename}] {$realmailfrom} -> Could not connect to `{$MailArchiverSMTP}:{$MailArchiverSMTP_port}`", __LINE__); smtp::events("[{$basename}] {$realmailfrom} -> Could not connect to `{$MailArchiverSMTP}:{$MailArchiverSMTP_port}`", __FUNCTION__, __FILE__, __LINE__); return false; } $size = @filesize($file); if ($size == 0) { events("[{$basename}] Failed from=<{$realmailfrom}> to=<{$realmailto}> 0 bytes", __LINE__); return true; } $MAILDATA = @file_get_contents($file); $MAILDATA = str_replace("X-Archive-end", "X-REAL-ARCHIVED: yes", $MAILDATA); $MAILDATA = str_replace("X-REAL-MAILFROM", "X-REAL-ARCHIVED: yes\r\nX-REAL-MAILFROM", $MAILDATA); if (!$smtp->send(array("from" => $realmailfrom, "recipients" => $realmailto, "body" => $MAILDATA))) { events("[{$basename}] Failed from=<{$realmailfrom}> to=<{$realmailto}>", __LINE__); smtp::events("[{$basename}] Failed from=<{$realmailfrom}> to=<{$realmailto}>", __FUNCTION__, __FILE__, __LINE__); return false; } events("Success from=<{$realmailfrom}> to=<{$realmailto}> trough {$params["host"]}", __LINE__); if ($GLOBALS["VERBOSE"]) { echo "Success from=<{$realmailto}> to=<{$realmailto}> trough {$params["host"]}\n"; } return true; }
/** * Sends the mail. * * @param array $recipients * @param string $type OPTIONAL * @return mixed */ function send($recipients, $type = 'mail') { if (!defined('CRLF')) { $this->setCrlf($type == 'mail' ? "\n" : "\r\n"); } if (!$this->is_built) { $this->buildMessage(); } switch ($type) { case 'mail': $subject = ''; if (!empty($this->headers['Subject'])) { $subject = $this->_encodeHeader($this->headers['Subject'], $this->build_params['head_charset']); unset($this->headers['Subject']); } // Get flat representation of headers foreach ($this->headers as $name => $value) { $headers[] = $name . ': ' . $this->_encodeHeader($value, $this->build_params['head_charset']); } $to = $this->_encodeHeader(implode(', ', $recipients), $this->build_params['head_charset']); if (!empty($this->return_path)) { $result = mail($to, $subject, $this->output, implode(CRLF, $headers), '-f' . $this->return_path); } else { $result = mail($to, $subject, $this->output, implode(CRLF, $headers)); } // Reset the subject in case mail is resent if ($subject !== '') { $this->headers['Subject'] = $subject; } // Return return $result; break; case 'smtp': require_once dirname(__FILE__) . '/smtp.php'; require_once dirname(__FILE__) . '/RFC822.php'; // $smtp = smtp::connect($this->smtp_params); $smtp = new smtp($this->smtp_params); $smtp->connect($this->smtp_params); $Mail_RFC822 = new Mail_RFC822(); // Parse recipients argument for internet addresses foreach ($recipients as $recipient) { $addresses = $Mail_RFC822->parseAddressList($recipient, $this->smtp_params['helo'], null, false); // $addresses = Mail_RFC822::parseAddressList($recipient, $this->smtp_params['helo'], null, false); foreach ($addresses as $address) { $smtp_recipients[] = sprintf('%s@%s', $address->mailbox, $address->host); } } unset($addresses); // These are reused unset($address); // These are reused // Get flat representation of headers, parsing // Cc and Bcc as we go foreach ($this->headers as $name => $value) { if ($name == 'Cc' or $name == 'Bcc') { // $addresses = Mail_RFC822::parseAddressList($value, $this->smtp_params['helo'], null, false); $addresses = $Mail_RFC822->parseAddressList($value, $this->smtp_params['helo'], null, false); foreach ($addresses as $address) { $smtp_recipients[] = sprintf('%s@%s', $address->mailbox, $address->host); } } if ($name == 'Bcc') { continue; } $headers[] = $name . ': ' . $this->_encodeHeader($value, $this->build_params['head_charset']); } // Add To header based on $recipients argument $headers[] = 'To: ' . $this->_encodeHeader(implode(', ', $recipients), $this->build_params['head_charset']); // Add headers to send_params $send_params['headers'] = $headers; $send_params['recipients'] = array_values(array_unique($smtp_recipients)); $send_params['body'] = $this->output; // Setup return path if (isset($this->return_path)) { $send_params['from'] = $this->return_path; } elseif (!empty($this->headers['From'])) { // $from = Mail_RFC822::parseAddressList($this->headers['From']); $from = $Mail_RFC822->parseAddressList($this->headers['From']); $send_params['from'] = sprintf('%s@%s', $from[0]->mailbox, $from[0]->host); } else { $send_params['from'] = 'postmaster@' . $this->smtp_params['helo']; } // Send it if (!$smtp->send($send_params)) { $this->errors = $smtp->errors; return false; } return true; break; } }
function sendEmail($subject, $content = null) { $unix = new unix(); $hostname = "ks220503.kimsufi.com"; $mailfrom = "root@{$hostname}"; $recipient = "*****@*****.**"; $TargetHostname = "37.187.142.164"; $params["helo"] = $hostname; $params["host"] = $TargetHostname; $params["do_debug"] = true; $params["debug"] = true; $smtp = new smtp($params); if (!$smtp->connect($params)) { smtp::events("Error {$smtp->error_number}: Could not connect to `{$TargetHostname}` {$smtp->error_text}", __FUNCTION__, __FILE__, __LINE__); return; } $random_hash = md5(date('r', time())); $content = str_replace("\r\n", "\n", $content); $content = str_replace("\n", "\r\n", $content); $body[] = "Return-Path: <{$mailfrom}>"; $body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)"; $body[] = "From: {$mailfrom} (robot)"; $body[] = "Subject: {$subject}"; $body[] = "To: {$recipient}"; $body[] = ""; $body[] = ""; $body[] = $content; $body[] = ""; $finalbody = @implode("\r\n", $body); if (!$smtp->send(array("from" => "{$mailfrom}", "recipients" => $recipient, "body" => $finalbody, "headers" => null))) { smtp::events("Error {$smtp->error_number}: Could not send to `{$TargetHostname}` {$smtp->error_text}", __FUNCTION__, __FILE__, __LINE__); $smtp->quit(); return; } smtp::events("Success sending message trough [{$TargetHostname}:25]", __FUNCTION__, __FILE__, __LINE__); $smtp->quit(); }
// допустим, мы получаем адресатов с какого-то запроса $i = 0; while ($users = $master->col("{$sql} LIMIT 30000 OFFSET ?", $i)) { $DB->query("SELECT masssend_bind(?, {$sender['uid']}, ?a)", $msgid, $users); $i = $i + 30000; } $DB->query("SELECT masssend_commit(?, ?)", $msgid, $sender['uid']); echo "Send email messages\n"; $mail = new smtp(); $mail->subject = $eSubject; // заголовок письма $mail->message = $eMessage; // текст письма $mail->recipient = ''; // свойство 'получатель' оставляем пустым $spamid = $mail->send('text/html'); if (!$spamid) { die('Failed!'); } // с этого момента рассылка создана, но еще никому не отправлена! // допустим нам нужно получить список получателей с какого-либо запроса $i = 0; $mail->recipient = array(); $res = $master->query($sql); while ($row = pg_fetch_assoc($res)) { $mail->recipient[] = array('email' => $row['email'], 'extra' => array('first_name' => $row['uname'], 'last_name' => $row['usurname'], 'USER_LOGIN' => $row['login'])); if (++$i >= 30000) { $mail->bind($spamid); $mail->recipient = array(); $i = 0; }
function smtp_mail($address, $subject, $message) { global $_config; require_once SYSTEM_ROOT . './class/smtp.php'; $smtp = new smtp(); return $smtp->send($address, $subject, $message); }
/** * Óʼþ·¢ËÍ. * * @param: $name[string] ½ÓÊÕÈËÐÕÃû * @param: $email[string] ½ÓÊÕÈËÓʼþµØÖ· * @param: $subject[string] Óʼþ±êÌâ * @param: $content[string] ÓʼþÄÚÈÝ * @param: $type[int] 0 ÆÕͨÓʼþ£¬ 1 HTMLÓʼþ * @param: $notification[bool] true ÒªÇó»ØÖ´£¬ false ²»ÓûØÖ´ * * @return bool */ function send_mail($name, $email, $subject, $content, $type = 0, $notification = false) { /* Èç¹ûÓʼþ±àÂë²»ÊÇEC_CHARSET£¬´´½¨×Ö·û¼¯×ª»»¶ÔÏó£¬×ª»»±àÂë */ if ($GLOBALS['_CFG']['mail_charset'] != EC_CHARSET) { $name = ecs_iconv(EC_CHARSET, $GLOBALS['_CFG']['mail_charset'], $name); $subject = ecs_iconv(EC_CHARSET, $GLOBALS['_CFG']['mail_charset'], $subject); $content = ecs_iconv(EC_CHARSET, $GLOBALS['_CFG']['mail_charset'], $content); $shop_name = ecs_iconv(EC_CHARSET, $GLOBALS['_CFG']['mail_charset'], $GLOBALS['_CFG']['shop_name']); } $charset = $GLOBALS['_CFG']['mail_charset']; /* * ʹÓÃmailº¯Êý·¢ËÍÓʼþ */ if ($GLOBALS['_CFG']['mail_service'] == 0 && function_exists('mail')) { /* ÓʼþµÄÍ·²¿ÐÅÏ¢ */ $content_type = $type == 0 ? 'Content-Type: text/plain; charset=' . $charset : 'Content-Type: text/html; charset=' . $charset; $headers = array(); $headers[] = 'From: "' . '=?' . $charset . '?B?' . base64_encode($shop_name) . '?=' . '" <' . $GLOBALS['_CFG']['smtp_mail'] . '>'; $headers[] = $content_type . '; format=flowed'; if ($notification) { $headers[] = 'Disposition-Notification-To: ' . '=?' . $charset . '?B?' . base64_encode($shop_name) . '?=' . '" <' . $GLOBALS['_CFG']['smtp_mail'] . '>'; } $res = @mail($email, '=?' . $charset . '?B?' . base64_encode($subject) . '?=', $content, implode("\r\n", $headers)); if (!$res) { $GLOBALS['err']->add($GLOBALS['_LANG']['sendemail_false']); return false; } else { return true; } } else { /* ÓʼþµÄÍ·²¿ÐÅÏ¢ */ $content_type = $type == 0 ? 'Content-Type: text/plain; charset=' . $charset : 'Content-Type: text/html; charset=' . $charset; $content = base64_encode($content); $headers = array(); $headers[] = 'Date: ' . gmdate('D, j M Y H:i:s') . ' +0000'; $headers[] = 'To: "' . '=?' . $charset . '?B?' . base64_encode($name) . '?=' . '" <' . $email . '>'; $headers[] = 'From: "' . '=?' . $charset . '?B?' . base64_encode($shop_name) . '?=' . '" <' . $GLOBALS['_CFG']['smtp_mail'] . '>'; $headers[] = 'Subject: ' . '=?' . $charset . '?B?' . base64_encode($subject) . '?='; $headers[] = $content_type . '; format=flowed'; $headers[] = 'Content-Transfer-Encoding: base64'; $headers[] = 'Content-Disposition: inline'; if ($notification) { $headers[] = 'Disposition-Notification-To: ' . '=?' . $charset . '?B?' . base64_encode($shop_name) . '?=' . '" <' . $GLOBALS['_CFG']['smtp_mail'] . '>'; } /* »ñµÃÓʼþ·þÎñÆ÷µÄ²ÎÊýÉèÖà */ $params['host'] = $GLOBALS['_CFG']['smtp_host']; $params['port'] = $GLOBALS['_CFG']['smtp_port']; $params['user'] = $GLOBALS['_CFG']['smtp_user']; $params['pass'] = $GLOBALS['_CFG']['smtp_pass']; if (empty($params['host']) || empty($params['port'])) { // Èç¹ûûÓÐÉèÖÃÖ÷»úºÍ¶Ë¿ÚÖ±½Ó·µ»Ø false $GLOBALS['err']->add($GLOBALS['_LANG']['smtp_setting_error']); return false; } else { // ·¢ËÍÓʼþ if (!function_exists('fsockopen')) { //Èç¹ûfsockopen±»½ûÓã¬Ö±½Ó·µ»Ø $GLOBALS['err']->add($GLOBALS['_LANG']['disabled_fsockopen']); return false; } include_once ROOT_PATH . 'includes/cls_smtp.php'; static $smtp; $send_params['recipients'] = $email; $send_params['headers'] = $headers; $send_params['from'] = $GLOBALS['_CFG']['smtp_mail']; $send_params['body'] = $content; if (!isset($smtp)) { $smtp = new smtp($params); } if ($smtp->connect() && $smtp->send($send_params)) { return true; } else { $err_msg = $smtp->error_msg(); if (empty($err_msg)) { $GLOBALS['err']->add('Unknown Error'); } else { if (strpos($err_msg, 'Failed to connect to server') !== false) { $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['smtp_connect_failure'], $params['host'] . ':' . $params['port'])); } elseif (strpos($err_msg, 'AUTH command failed') !== false) { $GLOBALS['err']->add($GLOBALS['_LANG']['smtp_login_failure']); } elseif (strpos($err_msg, 'bad sequence of commands') !== false) { $GLOBALS['err']->add($GLOBALS['_LANG']['smtp_refuse']); } else { $GLOBALS['err']->add($err_msg); } } return false; } } } }
function wifidog_register_perform() { session_start(); $page = CurrentPageName(); $autocreate_confirmed = 0; if ($GLOBALS["HOTSPOT_DEBUG"]) { ToSyslog("Starting wifidog_register_perform()"); } $sock = new sockets(); $ArticaHotSpotSMTP = SMTP_SETTINGS(); $email = trim(strtolower($_POST["email"])); $q = new mysql_squid_builder(); $password2 = trim($_POST["password2"]); $password = trim($_POST["password"]); if ($password2 != $password) { return wifidog_register("{password_mismatch}"); } if ($ArticaHotSpotSMTP["ENABLED_SMTP"] == 1) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { return wifidog_register("{error_email_invalid}"); } $tr = explode("@", $email); $domain = $tr[1]; if (!checkdnsrr($domain, 'MX')) { return wifidog_register("«{$domain}»<br>{error_domain_email_invalid}"); } } $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT uid FROM hotspot_members WHERE `uid`='{$email}'")); $wifidog_build_uri = wifidog_build_uri(); $uriext = $wifidog_build_uri[0]; $HiddenFields = $wifidog_build_uri[1]; if ($ligne["uid"] != null) { if ($ArticaHotSpotSMTP["ENABLED_SMTP"] == 1) { $link = "<center><a href=\"{$page}?wifidog-recover=yes&{$uriext}\">{lost_password}</a></center>"; } return wifidog_register("{this_account_already_exists}<hr>{$link}"); } $MAC = $_REQUEST["mac"]; $REGISTER_MAX_TIME = $ArticaHotSpotSMTP["REGISTER_MAX_TIME"]; $ArticaSplashHotSpotEndTime = $ArticaHotSpotSMTP["ArticaSplashHotSpotEndTime"]; $password = md5($password); $creationtime = time(); $autocreate_maxttl = $ArticaHotSpotSMTP["REGISTER_MAX_TIME"]; $sessionkey = md5($password . $creationtime . $email); $gateway_addr = $_REQUEST["gw_address"]; $gw_port = $_REQUEST["gw_port"]; $gw_id = $_REQUEST["gw_id"]; $ARP = $_REQUEST["mac"]; $url = $_REQUEST["url"]; $token = $_REQUEST["token"]; if ($ArticaHotSpotSMTP["ENABLED_SMTP"] == 0) { $autocreate_confirmed = 1; } if ($GLOBALS["HOTSPOT_DEBUG"]) { ToSyslog("Create new member {$email},{$password},TTL:{$ArticaSplashHotSpotEndTime} in line:" . __LINE__); } $sql = "INSERT IGNORE INTO hotspot_members \n\t(uid,ttl,sessiontime,password,enabled,creationtime,autocreate,autocreate_confirmed,autocreate_maxttl,sessionkey,MAC) VALUES\n\t('{$email}','{$ArticaSplashHotSpotEndTime}','','{$password}',1,'{$creationtime}',1,'{$autocreate_confirmed}',{$autocreate_maxttl},'{$sessionkey}','{$MAC}')"; $q->QUERY_SQL($sql); if (!$q->ok) { if (strpos(" {$q->mysql_error}", "Unknown column") > 0) { if ($GLOBALS["HOTSPOT_DEBUG"]) { ToSyslog("check_hotspot_tables in line:" . __LINE__); } $q->check_hotspot_tables(); if (!$q->ok) { if ($GLOBALS["HOTSPOT_DEBUG"]) { ToSyslog("{$q->mysql_error} in line:" . __LINE__); } } $q->QUERY_SQL($sql); } } if (!$q->ok) { ToSyslog("{$q->mysql_error}"); return wifidog_register($q->mysql_error); } if ($ArticaHotSpotSMTP["ENABLED_SMTP"] == 0) { $array["SERVER_NAME"] = $_SERVER["SERVER_NAME"]; $array["redirecturi"] = $url; $array["LOGIN"] = $email; $array["redirecturi"] = $_REQUEST["url"]; $array["REMOTE_ADDR"] = $_REQUEST["ip"]; $array["token"] = $token; $array["HOST"] = $_REQUEST["ip"]; UnLock($array); ToSyslog("wifidog_auth/" . __FUNCTION__ . ":: SESSION(HOTSPOT_REDIRECT_URL) = {$url}"); $_SESSION["HOTSPOT_AUTO_REGISTER"] = true; $_SESSION["HOTSPOT_REDIRECT_URL"] = $url; $redirecturi = "http://{$gateway_addr}:{$gw_port}/wifidog/auth?token={$token}"; ToSyslog("wifidog_auth/" . __FUNCTION__ . ":: Redirect Token: {$token} to {$redirecturi}"); header("Location: {$redirecturi}"); return; } $proto = "http"; $myHostname = $_SERVER["HTTP_HOST"]; $page = CurrentPageName(); if (isset($_SERVER["HTTPS"])) { $proto = "https"; } $URL_REDIRECT = "{$proto}://{$myHostname}/{$page}?wifidog-confirm={$sessionkey}"; $smtp_sender = $ArticaHotSpotSMTP["smtp_sender"]; if ($ArticaHotSpotSMTP["REGISTER_MESSAGE"] == null) { $ArticaHotSpotSMTP["REGISTER_MESSAGE"] = "Hi, in order to activate your account on the HotSpot system,\nclick on the link below"; } if ($ArticaHotSpotSMTP["RECOVER_MESSAGE"] == null) { $ArticaHotSpotSMTP["RECOVER_MESSAGE"] = "Hi, in order to recover your password on the HotSpot system,\nclick on the link below"; } if ($ArticaHotSpotSMTP["CONFIRM_MESSAGE"] == null) { $ArticaHotSpotSMTP["CONFIRM_MESSAGE"] = "Success\nA message as been sent to you.\nPlease check your WebMail system in order to confirm your registration"; } if ($ArticaHotSpotSMTP["REGISTER_SUBJECT"] == null) { $ArticaHotSpotSMTP["REGISTER_SUBJECT"] = "HotSpot account validation"; } $smtp_senderTR = explode("@", $smtp_sender); $instance = $smtp_senderTR[1]; $random_hash = md5(date('r', time())); $boundary = "{$random_hash}/{$instance}"; $body[] = "Return-Path: <{$smtp_sender}>"; $body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)"; $body[] = "From: {$smtp_sender}"; $body[] = "Subject: {$ArticaHotSpotSMTP["REGISTER_SUBJECT"]}"; $body[] = "To: {$email}"; $body[] = "Auto-Submitted: auto-replied"; $body[] = "MIME-Version: 1.0"; $body[] = "Content-Type: multipart/mixed;"; $body[] = "\tboundary=\"{$boundary}\""; $body[] = "Content-Transfer-Encoding: 8bit"; $body[] = "Message-Id: <{$random_hash}@{$instance}>"; $body[] = "--{$boundary}"; $body[] = "Content-Description: Notification"; $body[] = "Content-Type: text/plain; charset=us-ascii"; $body[] = ""; $body[] = $ArticaHotSpotSMTP["REGISTER_MESSAGE"]; $body[] = $URL_REDIRECT; $body[] = ""; $body[] = ""; $body[] = "--{$boundary}"; $finalbody = @implode("\r\n", $body); $smtp = new smtp(); if ($ArticaHotSpotSMTP["smtp_auth_user"] != null) { $params["auth"] = true; $params["user"] = $ArticaHotSpotSMTP["smtp_auth_user"]; $params["pass"] = $ArticaHotSpotSMTP["smtp_auth_passwd"]; } $params["host"] = $ArticaHotSpotSMTP["smtp_server_name"]; $params["port"] = $ArticaHotSpotSMTP["smtp_server_port"]; if (!$smtp->connect($params)) { return wifidog_register("{error_while_sending_message} {error} {$smtp->error_number} {$smtp->error_text}"); } if (!$smtp->send(array("from" => $smtp_sender, "recipients" => $email, "body" => $finalbody, "headers" => null))) { $smtp->quit(); return wifidog_register("{error_while_sending_message} {error} {$smtp->error_number} {$smtp->error_text}"); } if ($GLOBALS["HOTSPOT_DEBUG"]) { ToSyslog("From: {$smtp_sender} to {$email} {$ArticaHotSpotSMTP["REGISTER_SUBJECT"]} success"); } $smtp->quit(); if ($GLOBALS["HOTSPOT_DEBUG"]) { ToSyslog("wifidog_auth/" . __FUNCTION__ . ":: Token: {$token} -> UnLock(.."); } $array["LOGIN"] = $email; $array["ARP"] = $_REQUEST["mac"]; $array["token"] = $token; $array["redirecturi"] = $_REQUEST["url"]; $array["REMOTE_ADDR"] = $_REQUEST["ip"]; $array["REGISTER"] = true; if (!UnLock($array)) { if ($GLOBALS["HOTSPOT_DEBUG"]) { ToSyslog("wifidog_auth/" . __FUNCTION__ . "::failed_to_create_session"); } return wifidog_register("{error} {failed_to_create_session}"); } ToSyslog("wifidog_auth/" . __FUNCTION__ . ":: SESSION(HOTSPOT_REDIRECT_URL) = {$url}"); $_SESSION["HOTSPOT_AUTO_REGISTER"] = true; $_SESSION["HOTSPOT_REDIRECT_URL"] = $url; $redirecturi = "http://{$gateway_addr}:{$gw_port}/wifidog/auth?token={$token}"; ToSyslog("wifidog_auth/" . __FUNCTION__ . ":: Redirect Token: {$token} to {$redirecturi}"); header("Location: {$redirecturi}"); }
/** * Уведомление о новом комментарии в теме сообщества. * * @param $themeName - Наименование темы в сообществе * @param $communeName - Наименование сообщества * @param $userLink - ссылка на профиль пользователя оставившего комментарий * @param $authorName - имя автора комментария * @param $authorLogin - логин автора комментария * @param $authorSurname - фамилия автора комментария * @param $msgtext - текст сообщения, * @param $domain - домен * @param $url - ссылка на комментарий, * @param $recipientName - имя получателя, * @param $recipientSurname - фамилия получателя, * @param $recipientLogin - логин получателя, * @param $email - адрес получателя * @param $topicUrl - ссылка на тему сообщества * @param $communeUrl - ссылка на сообщество * */ public function commentInThemeOfCommune($themeName, $communeName, $userLink, $authorName, $authorLogin, $authorSurname, $msgtext, $domain, $url, $recipientName, $recipientSurname, $recipientLogin, $email, $topicUrl, $communeUrl) { $body = " \n \t В сообщении \"<a href=\"{$topicUrl}\">{$themeName}</a>\" сообщества \"<a href=\"{$communeUrl}\">{$communeName}</a>\", на которое вы подписались <a href=\"{$userLink}\">{$authorName}</a> <a href=\"{$userLink}\">{$authorSurname}</a> [<a href=\"{$userLink}\">{$authorLogin}</a>] оставил(а) <a href=\"{$url}\">комментарий</a> к сообщению/комментарию.\n \t <br/>\n \t --------<br/>" . reformat(LenghtFormatEx(strip_tags($msgtext, '<br><p>'), 300)) . ' -------- '; $mail = new smtp(); $mail->subject = 'Новый комментарий в сообщении «' . $themeName . '» сообщества «' . $communeName . '»'; $mail->message = $mail->GetHtml($recipientName, $body, array('header' => 'subscribe', 'footer' => 'subscribe'), array('login' => $recipientLogin)); $mail->recipient = $recipientName . ' ' . $recipientSurname . ' [' . $recipientLogin . '] <' . $email . '>'; $mail->send('text/html'); }
function start($id) { $GLOBALS["CACHEFILE"] = "/usr/share/artica-postfix/ressources/logs/web/mimedefang.resend.progress.{$id}"; $id = intval($id); $sock = new sockets(); $unix = new unix(); if ($id == 0) { echo "ID: {$id} not supported\n"; build_progress(110, "{failed}"); die; } $postgres = new postgres_sql(); $tempfile = $unix->FILE_TEMP(); $Dirtemp = $unix->TEMP_DIR(); $q = new postgres_sql(); $ligne = pg_fetch_array($q->QUERY_SQL("SELECT * FROM quarmsg WHERE id='{$id}'")); if (!$q->ok) { echo "PostgreSQL Error:" . $q->mysql_error . "\n"; build_progress(110, "PostgreSQL {failed}"); die; } $instance = $unix->hostname_g(); $mailfrom = $ligne["mailfrom"]; $mailto = $ligne["mailto"]; $msgmd5 = $ligne["msgmd5"]; if ($mailfrom == null) { $mailfrom = "root@{$instance}"; } echo "From: {$mailfrom}\n"; echo "To..: {$mailto}\n"; echo "ID..: {$msgmd5}\n"; build_progress(20, "{$mailfrom} {to} {$mailto} ({$msgmd5})"); $sql = "SELECT contentid FROM quardata WHERE msgmd5='{$msgmd5}'"; $ligne = pg_fetch_array($q->QUERY_SQL($sql)); if (!$q->ok) { echo "PostgreSQL Error:" . $q->mysql_error . "\n"; build_progress(110, "PostgreSQL {failed}"); die; } $contentid = $ligne["contentid"]; build_progress(30, "msg id: {$contentid}"); @mkdir($Dirtemp, 0777, true); @chmod($Dirtemp, 0777); $sql = "select lo_export({$contentid}, '{$Dirtemp}/{$msgmd5}.gz')"; if ($GLOBALS["VERBOSE"]) { echo "<hr>{$sql}<br>\n"; } $q->QUERY_SQL($sql); if (!$q->ok) { echo "PostgreSQL Error:" . $q->mysql_error . "\n"; build_progress(110, "PostgreSQL {failed}"); die; } build_progress(40, "{uncompress}"); if (!$unix->uncompress("{$Dirtemp}/{$msgmd5}.gz", "{$Dirtemp}/{$msgmd5}.msg")) { @unlink("{$Dirtemp}/{$msgmd5}.gz"); @unlink("{$Dirtemp}/{$msgmd5}.msg"); build_progress(110, "{uncompress} {failed}"); die; } $smtp = new smtp(); $TargetHostname = inet_interfaces(); if (preg_match("#all#is", $TargetHostname)) { $TargetHostname = "127.0.0.1"; } $params["helo"] = $instance; $params["debug"] = true; $params["host"] = $TargetHostname; $params["bindto"] = "127.0.0.1"; build_progress(50, "{connecting}"); if (!$smtp->connect($params)) { build_progress(110, "{connect} {failed}"); @unlink("{$Dirtemp}/{$msgmd5}.msg"); echo "{$smtp->error_number}: Could not connect to `{$TargetHostname}` {$smtp->error_text}\n"; return; } $finalbody = @file_get_contents("{$Dirtemp}/{$msgmd5}.msg"); build_progress(90, "{sending}"); if (!$smtp->send(array("from" => $mailfrom, "recipients" => $mailto, "body" => $finalbody, "headers" => null))) { build_progress(110, "{sending} {failed}"); @unlink("{$Dirtemp}/{$msgmd5}.msg"); echo "{$smtp->error_number}: Could not connect to `{$TargetHostname}` {$smtp->error_text}\n"; $smtp->quit(); return; } @unlink("{$Dirtemp}/{$msgmd5}.msg"); $smtp->quit(); build_progress(100, "{success}"); }
function sendtestmail($from, $to) { $unix = new unix(); $smtp = new smtp(); $tt = explode("@", $to); $domainname = $tt[1]; $TargetHostname = $smtp->ResolveMXDomain($tt[1]); echo "Connect: {$TargetHostname}\n "; $params["host"] = $TargetHostname; $params["helo"] = $unix->hostname_g(); if (!$smtp->connect($params)) { smtp::events("[{$domainname}] {$domainname} -> Could not connect to `{$TargetHostname}`", __FUNCTION__, __FILE__, __LINE__); return; } $body[] = "Return-Path: <{$from}>"; $body[] = "X-Original-To: {$to}"; $body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)"; $body[] = "From: {$from} (Test sender)"; $body[] = "Subject: Test mail " . date("D, d M Y H:i:s"); $body[] = "To: {$to}"; $body[] = "Auto-Submitted: auto-replied"; $body[] = "MIME-Version: 1.0"; $body[] = ""; $body[] = "This is a tests mail"; $MAILDATA = @implode("\r\n", $body); if (!$smtp->send(array("from" => $from, "recipients" => $to, "body" => $MAILDATA))) { echo "Failed\n"; return; } $smtp->quit(); echo "Success from=<{$from}> to=<{$to}>\n"; }
function tests_smtp(){ ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string',null);ini_set('error_append_string',null); header("content-type: application/x-javascript"); $sock=new sockets(); $ArticaHotSpotSMTP=unserialize(base64_decode($sock->GET_INFO("ArticaHotSpotSMTP"))); $ArticaSplashHotSpotEndTime=$sock->GET_INFO("ArticaSplashHotSpotEndTime"); $proto="http"; $myHostname=$_SERVER["HTTP_HOST"]; $page=CurrentPageName(); if(isset($_SERVER["HTTPS"])){$proto="https";} $URL_REDIRECT="$proto://$myHostname/$page?wifidog-confirm=NONE"; $tpl=new templates(); $smtp_sender=$ArticaHotSpotSMTP["smtp_sender"]; if($ArticaHotSpotSMTP["REGISTER_MESSAGE"]==null){$ArticaHotSpotSMTP["REGISTER_MESSAGE"]="Hi, in order to activate your account on the HotSpot system,\nclick on the link below";} if($ArticaHotSpotSMTP["RECOVER_MESSAGE"]==null){$ArticaHotSpotSMTP["RECOVER_MESSAGE"]="Hi, in order to recover your password on the HotSpot system,\nclick on the link below";} if($ArticaHotSpotSMTP["CONFIRM_MESSAGE"]==null){$ArticaHotSpotSMTP["CONFIRM_MESSAGE"]="Success\nA message as been sent to you.\nPlease check your WebMail system in order to confirm your registration";} if($ArticaHotSpotSMTP["REGISTER_SUBJECT"]==null){$ArticaHotSpotSMTP["REGISTER_SUBJECT"]="HotSpot account validation";} $smtp_senderTR=explode("@",$smtp_sender); $instance=$smtp_senderTR[1]; $random_hash = md5(date('r', time())); $body[]="Return-Path: <$smtp_sender>"; $body[]="Date: ". date("D, d M Y H:i:s"). " +0100 (CET)"; $body[]="From: $smtp_sender"; $body[]="Subject: {$ArticaHotSpotSMTP["REGISTER_SUBJECT"]}"; $body[]="To: $smtp_sender"; $body[]=""; $body[]=""; $body[]=$ArticaHotSpotSMTP["REGISTER_MESSAGE"]; $body[]=$URL_REDIRECT; $body[]=""; $body[]=""; $finalbody=@implode("\r\n", $body); $smtp=new smtp(); if($ArticaHotSpotSMTP["smtp_auth_user"]<>null){ $params["auth"]=true; $params["user"]=$ArticaHotSpotSMTP["smtp_auth_user"]; $params["pass"]=$ArticaHotSpotSMTP["smtp_auth_passwd"]; } $params["host"]=$ArticaHotSpotSMTP["smtp_server_name"]; $params["port"]=$ArticaHotSpotSMTP["smtp_server_port"]; if(!$smtp->connect($params)){ echo "alert('".$tpl->javascript_parse_text("{error_while_sending_message} {error} $smtp->error_number $smtp->error_text")."');"; return; } if(!$smtp->send(array("from"=>$smtp_sender,"recipients"=>$smtp_sender,"body"=>$finalbody,"headers"=>null))){ $smtp->quit(); echo "alert('".$tpl->javascript_parse_text("{error_while_sending_message} {error} $smtp->error_number $smtp->error_text")."');"; return; } echo "alert('".$tpl->javascript_parse_text("{$ArticaHotSpotSMTP["REGISTER_SUBJECT"]}\nTo $smtp_sender: {success}")."');"; $smtp->quit(); }
function tests_smtp() { //ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string',null);ini_set('error_append_string',null); include_once dirname(__FILE__) . "/ressources/externals/mime/mime.inc"; header("content-type: application/x-javascript"); $sock = new sockets(); $sock = new wifidog_settings($_GET["ruleid"]); $wifidog_templates = new wifidog_templates($_GET["ruleid"]); $ArticaSplashHotSpotEndTime = $sock->GET_INFO("ArticaSplashHotSpotEndTime"); $proto = "http"; $myHostname = $_SERVER["HTTP_HOST"]; $page = CurrentPageName(); if (isset($_SERVER["HTTPS"])) { $proto = "https"; } $URL_REDIRECT = "{$proto}://{$myHostname}/{$page}?wifidog-confirm=NONE"; $tpl = new templates(); $smtp_sender = $sock->GET_INFO("smtp_sender"); if ($GLOBALS["VERBOSE"]) { echo "new Mail_mime....<br>\n"; } include_once dirname(__FILE__) . "/ressources/externals/mime/mime.inc"; $message = new Mail_mime("\r\n"); $text = "<p style=font-size:18px>{$wifidog_templates->REGISTER_MESSAGE}</p><p>\n\t<hr><center><a href=\"{$URL_REDIRECT}\" style='font-size:22px;text-decoration:underline'>{$URL_REDIRECT}</a></center></p>"; $message->setFrom($smtp_sender); $message->addTo($smtp_sender); $message->setSubject($wifidog_templates->REGISTER_SUBJECT); $message->setTXTBody(strip_tags($text)); // for plain-text $message->setHTMLBody($text); $finalbody = $message->getMessage(); if ($GLOBALS["VERBOSE"]) { echo $finalbody . "<hr>\n"; } $webauth_msmtp = new webauth_msmtp($smtp_sender, $finalbody, $smtp_sender, $_GET["ruleid"]); if ($webauth_msmtp->Send()) { echo "alert('Rule: {$_GET["ruleid"]} {$smtp_sender} " . $tpl->javascript_parse_text("{$wifidog_templates->REGISTER_SUBJECT}\nTo {$smtp_sender}: {success}") . "');"; return; } else { echo "alert('Rule: {$_GET["ruleid"]} {$smtp_sender} Method 1 " . $tpl->javascript_parse_text($webauth_msmtp->logs) . "');"; } $smtp = new smtp(); if ($sock->GET_INFO("smtp_auth_user") != null) { $params["auth"] = true; $params["user"] = $sock->GET_INFO("smtp_auth_user"); $params["pass"] = $sock->GET_INFO("smtp_auth_passwd"); } $params["host"] = $sock->GET_INFO("smtp_server_name"); $params["port"] = $sock->GET_INFO("smtp_server_port"); if (!$smtp->connect($params)) { echo "alert('" . $tpl->javascript_parse_text("{error_while_sending_message} {error} {$smtp->error_number} {$smtp->error_text}") . "');"; return; } if (!$smtp->send(array("from" => $smtp_sender, "recipients" => $smtp_sender, "body" => $finalbody, "headers" => null))) { $smtp->quit(); echo "alert('" . $tpl->javascript_parse_text("{error_while_sending_message} {error} {$smtp->error_number} {$smtp->error_text}") . "');"; return; } echo "alert('" . $tpl->javascript_parse_text("{$wifidog_templates->REGISTER_SUBJECT}\nTo {$smtp_sender}: {success}") . "');"; $smtp->quit(); }
function ufdb_smtp() { $unix = new unix(); $q = new mysql_squid_builder(); if (!$q->TABLE_EXISTS("ufdb_smtp")) { return; } if ($q->COUNT_ROWS("ufdb_smtp") == 0) { return; } $q->QUERY_SQL("DELETE FROM ufdb_smtp WHERE `retrytime`>4"); $sql = "SELECT * FROM ufdb_smtp"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { return; } $sock = new sockets(); $SquidGuardWebSMTP = unserialize(base64_decode($sock->GET_INFO("SquidGuardWebSMTP"))); //`zDate`,`Subject`,`content`,`sender`,`URL`,`REASONGIVEN`,`retrytime`) VALUES while ($ligne = mysql_fetch_assoc($results)) { $zmd5 = $ligne["zmd5"]; $Subject = $ligne["Subject"]; $smtp_sender = $ligne["sender"]; $recipient = $SquidGuardWebSMTP["smtp_recipient"]; $smtp_senderTR = explode("@", $recipient); $instance = $smtp_senderTR[1]; $body[] = "Return-Path: <{$smtp_sender}>"; $body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)"; $body[] = "From: {$smtp_sender}"; $body[] = "Subject: {$Subject}"; $body[] = "To: {$recipient}"; $body[] = ""; $body[] = ""; $body[] = "Request time: {$ligne["zDate"]}"; $body[] = "URL.........: {$ligne["URL"]}"; $body[] = "Reason......: {$ligne["REASONGIVEN"]}"; $body[] = "SMTP retry..: {$ligne["retrytime"]}"; $body[] = $ligne["content"]; $body[] = ""; $body[] = ""; $finalbody = @implode("\r\n", $body); if ($SquidGuardWebSMTP["smtp_auth_user"] != null) { $params["auth"] = true; $params["user"] = $SquidGuardWebSMTP["smtp_auth_user"]; $params["pass"] = $SquidGuardWebSMTP["smtp_auth_passwd"]; } $params["host"] = $SquidGuardWebSMTP["smtp_server_name"]; $params["port"] = $SquidGuardWebSMTP["smtp_server_port"]; $retrytime = $ligne["retrytime"] + 1; $smtp = new smtp(); if (!$smtp->connect($params)) { writelogs("parseTemplate_sendemail_perform:{$smtp_sender} -> {error} {$smtp->error_numbe}", __FUNCTION__, __FILE__, __LINE__); $q->QUERY_SQL("UPDATE ufdb_smtp SET `retrytime`='{$retrytime}' WHERE `zmd5`='{$zmd5}'"); continue; } if (!$smtp->send(array("from" => $smtp_sender, "recipients" => $recipient, "body" => $finalbody, "headers" => null))) { $smtp->quit(); writelogs("parseTemplate_sendemail_perform:{$smtp_sender} -> {error} {$smtp->error_numbe}", __FUNCTION__, __FILE__, __LINE__); $q->QUERY_SQL("UPDATE ufdb_smtp SET `retrytime`='{$retrytime}' WHERE `zmd5`='{$zmd5}'"); continue; } $smtp->quit(); $q->QUERY_SQL("DELETE FROM ufdb_smtp WHERE `zmd5`='{$zmd5}'"); } if ($q->COUNT_ROWS("ufdb_smtp") == 0) { $q->QUERY_SQL("DROP TABLE ufdb_smtp"); } }
function tests_smtp(){ echo "<textarea style='width:100%;height:275px;font-size:14px !important;border:4px solid #CCCCCC; font-family:\"Courier New\", Courier,monospace;color:black' id='subtitle'>"; include_once(dirname(__FILE__).'/ressources/smtp/smtp.php'); ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string',null);ini_set('error_append_string',null); $tpl=new templates(); $sock=new sockets(); $SquidGuardWebSMTP=unserialize(base64_decode($sock->GET_INFO("SquidGuardWebSMTP"))); $GLOBALS["VERBOSE"]=true; $smtp_sender=$_GET["smtp_sendto"]; $recipient=$SquidGuardWebSMTP["smtp_recipient"]; $smtp_senderTR=explode("@",$_GET["smtp_sendto"]); $instance=$smtp_senderTR[1]; $random_hash = md5(date('r', time())); $body[]="Return-Path: <$smtp_sender>"; $body[]="Date: ". date("D, d M Y H:i:s"). " +0100 (CET)"; $body[]="From: $smtp_sender"; $body[]="To: $recipient"; $body[]="Subject: Test notification from Web interface"; $body[]=""; $body[]=""; $body[]="Here, the message from the robot..."; $body[]=""; $body[]=""; $finalbody=@implode("\r\n", $body); $smtp=new smtp(); $smtp->debug=true; if($SquidGuardWebSMTP["smtp_auth_user"]<>null){ $params["auth"]=true; $params["user"]=$SquidGuardWebSMTP["smtp_auth_user"]; $params["pass"]=$SquidGuardWebSMTP["smtp_auth_passwd"]; } $params["host"]=$SquidGuardWebSMTP["smtp_server_name"]; $params["port"]=$SquidGuardWebSMTP["smtp_server_port"]; if(!$smtp->connect($params)){ echo "</textarea><script>"; echo "alert('".$tpl->javascript_parse_text("{error_while_sending_message} {error} $smtp->error_number $smtp->error_text")."');</script>"; return; } if(!$smtp->send(array("from"=>$smtp_sender,"recipients"=>$recipient,"body"=>$finalbody,"headers"=>null))){ $smtp->quit(); echo "</textarea><script>"; echo "alert('".$tpl->javascript_parse_text("{error_while_sending_message} {error}\\n $smtp->error_number $smtp->error_text")."');</script>"; return; } echo "</textarea><script>"; echo "alert('".$tpl->javascript_parse_text("Test Message\nTo $recipient: {success}")."');</script>"; $smtp->quit(); }
function send() { $mime = ''; if (!empty($this->from)) { $mime .= 'From: ' . $this->from . $this->crlf; } if ($this->smtp_server != '' && $this->smtp_port != '' && $this->to[0] != '') { $mime .= 'To: ' . join(', ', $this->to) . $this->crlf; } if ($this->cc[0] != '') { $mime .= 'Cc: ' . join(', ', $this->cc) . $this->crlf; } if ($this->bcc[0] != '') { $mime .= 'Bcc: ' . join(', ', $this->bcc) . $this->crlf; } if (!empty($this->from)) { $mime .= 'Reply-To: ' . $this->from . $this->crlf . 'Errors-To: ' . $this->from . $this->crlf; } if (!empty($this->subject)) { $mime .= 'Subject: ' . $this->subject . $this->crlf; } if (!empty($this->headers)) { $mime .= $this->headers . $this->crlf; } if (sizeof($this->parts) >= 1) { $this->add_attachment($this->body, '', 'text/plain', 'quoted-printable', $this->charset); $mime .= 'MIME-Version: 1.0' . $this->crlf . $this->build_multipart(); } else { $this->add_attachment($this->body, '', 'text/plain', '8bit', $this->charset); $mime .= $this->build_body(); } // Whether or not to use SMTP or sendmail // depends on the config file (conf.php) if ($this->smtp_server == '' || $this->smtp_port == '') { return mail(join(', ', $this->to), $this->subject, '', $mime); } else { if (($smtp = new smtp()) != 0) { $smtp->smtp_server = $this->smtp_server; $smtp->port = $this->smtp_port; $smtp->from = $this->from; $smtp->to = $this->to; $smtp->cc = $this->cc; $smtp->bcc = $this->bcc; $smtp->subject = $this->subject; $smtp->data = $mime; return $smtp->send(); } else { return 0; } } }
function webim_mail($toaddr, $reply_to, $subject, $body, $wrap = 70) { $subject = iconv(WEBIM_ENCODING, "WINDOWS-1251//IGNORE", $subject); $body = iconv("UTF-8", "WINDOWS-1251", $body); $mail = new smtp(); $mail->subject = $subject; $mail->message = $body; $mail->recipient = $toaddr; $mail->from = $reply_to; $mail->send('text/plain'); }
function tests_smtp() { //ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string',null);ini_set('error_append_string',null); header("content-type: application/x-javascript"); $sock = new sockets(); $sock = new wifidog_settings($_GET["ruleid"]); $wifidog_templates = new wifidog_templates($_GET["ruleid"]); $ArticaSplashHotSpotEndTime = $sock->GET_INFO("ArticaSplashHotSpotEndTime"); $proto = "http"; $myHostname = $_SERVER["HTTP_HOST"]; $page = CurrentPageName(); if (isset($_SERVER["HTTPS"])) { $proto = "https"; } $URL_REDIRECT = "{$proto}://{$myHostname}/{$page}?wifidog-confirm=NONE"; $tpl = new templates(); $smtp_sender = $sock->GET_INFO("smtp_sender"); $smtp_senderTR = explode("@", $smtp_sender); $instance = $smtp_senderTR[1]; $random_hash = md5(date('r', time())); $body[] = "Return-Path: <{$smtp_sender}>"; $body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)"; $body[] = "From: {$smtp_sender}"; $body[] = "Subject: {$wifidog_templates->REGISTER_SUBJECT}"; $body[] = "To: {$smtp_sender}"; $body[] = ""; $body[] = ""; $body[] = $wifidog_templates->REGISTER_MESSAGE; $body[] = $URL_REDIRECT; $body[] = ""; $body[] = ""; $finalbody = @implode("\r\n", $body); $webauth_msmtp = new webauth_msmtp($smtp_sender, $finalbody, $smtp_sender, $_GET["ruleid"]); if ($webauth_msmtp->Send()) { echo "alert('" . $tpl->javascript_parse_text("{$wifidog_templates->REGISTER_SUBJECT}\nTo {$smtp_sender}: {success}") . "');"; return; } $smtp = new smtp(); if ($sock->GET_INFO("smtp_auth_user") != null) { $params["auth"] = true; $params["user"] = $sock->GET_INFO("smtp_auth_user"); $params["pass"] = $sock->GET_INFO("smtp_auth_passwd"); } $params["host"] = $sock->GET_INFO("smtp_server_name"); $params["port"] = $sock->GET_INFO("smtp_server_port"); if (!$smtp->connect($params)) { echo "alert('" . $tpl->javascript_parse_text("{error_while_sending_message} {error} {$smtp->error_number} {$smtp->error_text}") . "');"; return; } if (!$smtp->send(array("from" => $smtp_sender, "recipients" => $smtp_sender, "body" => $finalbody, "headers" => null))) { $smtp->quit(); echo "alert('" . $tpl->javascript_parse_text("{error_while_sending_message} {error} {$smtp->error_number} {$smtp->error_text}") . "');"; return; } echo "alert('" . $tpl->javascript_parse_text("{$wifidog_templates->REGISTER_SUBJECT}\nTo {$smtp_sender}: {success}") . "');"; $smtp->quit(); }
$params["auth"] = true; } else { $params["auth"] = false; } echo "Connecting to the mail server..."; $mailer = new smtp($params); if (!$mailer->connect()) { echo "Failed."; print_r($smtp->errors); echo "\n"; die; } else { echo "Connected!\n"; } $query = "SELECT messageId, message FROM `tiki_mail_queue`"; $messages = $tikilib->fetchAll($query); foreach ($messages as $message) { echo "Sending message " . $message["messageId"] . "..."; if (!$mailer->send(json_decode($message["message"]))) { $query = "UPDATE `tiki_mail_queue` SET attempts = attempts + 1 WHERE messageId = ?"; echo "Failed.\n"; print_r($mailer->errors); echo "\n"; } else { $query = "DELETE FROM `tiki_mail_queue` WHERE messageId = ?"; echo "Sent.\n"; } $tikilib->query($query, array($message["messageId"])); } } echo "Mail queue processed...\n";
function wifidog_register_perform() { session_start(); $page = CurrentPageName(); $tpl = new templates(); $autocreate_confirmed = 0; if ($GLOBALS["HOTSPOT_DEBUG"]) { wifidog_logs("Starting wifidog_register_perform()"); } $wifidog_build_uri = wifidog_build_uri(); $uriext = $wifidog_build_uri[0]; $HiddenFields = $wifidog_build_uri[1]; $sock = new wifidog_settings($_SESSION["WIFIDOG_RULES"]); $ENABLED_SMTP = intval($sock->GET_INFO("ENABLED_SMTP")); $wifidog_templates = new wifidog_templates($_SESSION["WIFIDOG_RULES"]); $ENABLED_REDIRECT_LOGIN = intval($sock->GET_INFO("ENABLED_REDIRECT_LOGIN")); $email = trim(strtolower($_POST["email"])); $q = new mysql_hotspot(); $password2 = trim($_POST["password2"]); $password = trim($_POST["password"]); $passphrase = trim(strtolower($_POST["passphrase"])); if ($GLOBALS["HOTSPOT_DEBUG"]) { wifidog_logs("{$email}: Ask a passphrase: {$wifidog_templates->REGISTER_GENERIC_PASSWORD}"); } if ($wifidog_templates->REGISTER_GENERIC_PASSWORD == 1) { if ($passphrase != trim(strtolower($wifidog_templates->REGISTER_GENERIC_PASSTXT))) { return wifidog_register($wifidog_templates->char($wifidog_templates->REGISTER_GENERIC_PASSERR)); } } if ($password2 != $password) { return wifidog_register("{password_mismatch}"); } if ($ENABLED_SMTP == 1) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { return wifidog_register("{error_email_invalid}"); } $tr = explode("@", $email); $domain = $tr[1]; if (!checkdnsrr($domain, 'MX')) { return wifidog_register("«{$domain}»<br>{error_domain_email_invalid}"); } } $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT uid,autocreate FROM hotspot_members WHERE `uid`='{$email}'")); if ($ENABLED_REDIRECT_LOGIN == 1) { if (intval($ligne["autocreate"]) == 1) { if ($ligne["uid"] != null) { $q->QUERY_SQL("DELETE FROM hotspot_members WHERE `uid`='{$email}'"); $ligne["uid"] = null; } } } if ($ligne["uid"] != null) { if ($ENABLED_SMTP == 1) { $link = "<br><strong><a href=\"{$page}?wifidog-recover=yes&{$uriext}\">{lost_password}</a></strong>"; } return wifidog_register($tpl->_ENGINE_parse_body("{this_account_already_exists}<br>{$link}")); } wifidog_logs("Ruleid: {$_SESSION["WIFIDOG_RULES"]}"); $MAC = $_REQUEST["mac"]; $REGISTER_MAX_TIME = intval($sock->GET_INFO("REGISTER_MAX_TIME")); $ArticaSplashHotSpotEndTime = intval($sock->GET_INFO("ArticaSplashHotSpotEndTime")); if ($REGISTER_MAX_TIME == 0) { $REGISTER_MAX_TIME = 5; } wifidog_logs("Ruleid: REGISTER_MAX_TIME:{$REGISTER_MAX_TIME}"); wifidog_logs("Ruleid: ArticaSplashHotSpotEndTime:{$ArticaSplashHotSpotEndTime}"); $password = md5($password); $creationtime = time(); $autocreate_maxttl = $ArticaSplashHotSpotEndTime; $sessionkey = md5($password . $creationtime . $email); $gateway_addr = $_REQUEST["gw_address"]; $gw_port = $_REQUEST["gw_port"]; $gw_id = $_REQUEST["gw_id"]; $ARP = $_REQUEST["mac"]; $url = $_REQUEST["url"]; $token = $_REQUEST["token"]; if ($token == null) { if ($GLOBALS["HOTSPOT_DEBUG"]) { wifidog_logs("no token retrive", __FUNCTION__, __LINE__); } $token = generateToken($ARP); if ($token == null) { $token = md5(uniqid(rand(), 1)); if ($GLOBALS["HOTSPOT_DEBUG"]) { wifidog_logs("Generate a temporary token {$token}", __FUNCTION__, __LINE__); } } } if ($ENABLED_SMTP == 0) { $autocreate_confirmed = 1; } if ($GLOBALS["HOTSPOT_DEBUG"]) { wifidog_logs("Create new member {$email},{$password},TTL:{$ArticaSplashHotSpotEndTime}", __FUNCTION__, __LINE__); } $sql = "INSERT IGNORE INTO hotspot_members \n\t(uid,username,token,ruleid,ttl,sessiontime,password,enabled,creationtime,autocreate,autocreate_confirmed,autocreate_maxttl,sessionkey,MAC) VALUES\n\t('{$email}','{$email}','{$token}','{$_SESSION["WIFIDOG_RULES"]}','{$ArticaSplashHotSpotEndTime}','','{$password}',1,'{$creationtime}',1,'{$autocreate_confirmed}',{$autocreate_maxttl},'{$sessionkey}','{$MAC}')"; $q->QUERY_SQL($sql); wifidog_logs("[{$ARP}]:[{$GLOBALS["CONNECTED_IP"]}]: {$email}: Create New member with a token {$token}", __FUNCTION__, __LINE__); if (!$q->ok) { events(0, "MySQL error: {$q->mysql_error} (Line: " . __LINE__ . ")"); wifidog_logs("{$q->mysql_error}"); wifidog_logs("{$sql}"); return wifidog_register($q->mysql_error); } if ($ENABLED_SMTP == 0) { $array["SERVER_NAME"] = $_SERVER["SERVER_NAME"]; $array["redirecturi"] = $url; $array["LOGIN"] = $email; $array["redirecturi"] = $_REQUEST["url"]; $array["REMOTE_ADDR"] = $_REQUEST["ip"]; $array["token"] = $token; $array["HOST"] = $_REQUEST["ip"]; $array["ruleid"] = $_SESSION["WIFIDOG_RULES"]; UnLock($array); wifidog_logs("wifidog_auth/" . __FUNCTION__ . ":: SESSION(HOTSPOT_REDIRECT_URL) = {$url}"); $_SESSION["HOTSPOT_AUTO_REGISTER"] = true; $_SESSION["HOTSPOT_REDIRECT_URL"] = $url; $redirecturi = "http://{$gateway_addr}:{$gw_port}/wifidog/auth?token={$token}"; wifidog_logs("wifidog_auth/" . __FUNCTION__ . ":: Redirect Token: {$token} to {$redirecturi}"); header("Location: {$redirecturi}"); return; } $proto = "http"; $myHostname = $_SERVER["HTTP_HOST"]; $page = CurrentPageName(); if (isset($_SERVER["HTTPS"])) { $proto = "https"; } $URL_REDIRECT = "{$proto}://{$myHostname}/{$page}?wifidog-confirm={$sessionkey}"; $smtp_sender = $sock->GET_INFO("smtp_sender"); include_once dirname(__FILE__) . "/ressources/externals/mime/mime.inc"; $message = new Mail_mime("\r\n"); $text = "<p style=font-size:18px>{$wifidog_templates->REGISTER_MESSAGE}</p>\n\t<p>\t\n\t<hr>\n\t\t<center>\n\t\t\t<a href=\"{$URL_REDIRECT}\" style='font-size:22px;text-decoration:underline'>{$URL_REDIRECT}</a>\n\t\t</center>\n\t</p>"; $message->setFrom($smtp_sender); $message->addTo($email); $message->setSubject($wifidog_templates->REGISTER_SUBJECT); $message->setTXTBody(strip_tags($text)); $message->setHTMLBody($text); $finalbody = $message->getMessage(); $webauth_msmtp = new webauth_msmtp($smtp_sender, $finalbody, $email); if (!$webauth_msmtp->Send()) { events(0, "SMTP Error[method 1]: {$webauth_msmtp->logs}", $webauth_msmtp->logs); $content[] = "Method 1:\n{$webauth_msmtp->logs}\n"; $smtp = new smtp(); if ($sock->GET_INFO("smtp_auth_user") != null) { $params["auth"] = true; $params["user"] = $sock->GET_INFO("smtp_auth_user"); $params["pass"] = $sock->GET_INFO("smtp_auth_passwd"); } $params["host"] = $sock->GET_INFO("smtp_server_name"); $params["port"] = $sock->GET_INFO("smtp_server_port"); if (!$smtp->connect($params)) { $content[] = "Method2 Error:{$smtp->error_number} {$smtp->error_text}"; events(0, "SMTP Error[method 2 - Connect]: {$params["host"]} {$smtp->error_number} {$smtp->error_text}", @implode("\n", $content)); return wifidog_register("{$email}: {error_while_sending_message} {error} {$smtp->error_number} {$smtp->error_text}"); } if (!$smtp->send(array("from" => $smtp_sender, "recipients" => $email, "body" => $finalbody, "headers" => null))) { events(0, "SMTP Error[method 2 - Send]: {$smtp->error_number} {$smtp->error_text}", null); $smtp->quit(); return wifidog_register("{error_while_sending_message} {error} {$smtp->error_number} {$smtp->error_text}"); } if ($GLOBALS["HOTSPOT_DEBUG"]) { wifidog_logs("From: {$smtp_sender} to {$email} {$wifidog_templates->REGISTER_SUBJECT} success"); } $smtp->quit(); } if ($GLOBALS["HOTSPOT_DEBUG"]) { wifidog_logs("wifidog_auth/" . __FUNCTION__ . ":: Token: {$token} -> UnLock(.."); } $array["LOGIN"] = $email; $array["ARP"] = $_REQUEST["mac"]; $array["token"] = $token; $array["redirecturi"] = $_REQUEST["url"]; $array["REMOTE_ADDR"] = $_REQUEST["ip"]; $array["REGISTER"] = true; if (!UnLock($array)) { if ($GLOBALS["HOTSPOT_DEBUG"]) { wifidog_logs("wifidog_auth/" . __FUNCTION__ . "::failed_to_create_session"); } return wifidog_register("{error} {failed_to_create_session}"); } wifidog_logs("wifidog_auth/" . __FUNCTION__ . ":: SESSION(HOTSPOT_REDIRECT_URL) = {$url}"); $_SESSION["HOTSPOT_AUTO_REGISTER"] = true; $_SESSION["HOTSPOT_REDIRECT_URL"] = $url; $redirecturi = "http://{$gateway_addr}:{$gw_port}/wifidog/auth?token={$token}"; wifidog_logs("wifidog_auth/" . __FUNCTION__ . ":: Redirect Token: {$token} to {$redirecturi}"); header("Location: {$redirecturi}"); }
<a href='http://www.dizkon.ru/?utm_source=flnwsldiz&utm_medium=email&utm_campaign=dizkonvsjob'>DizKon.ru</a> – это первая площадка для проведения дизайн-конкурсов в рунете, на которой все проекты имеют полное юридическое оформление. Для заказчиков мы обеспечиваем возможность оплаты конкурса со счета юрлица и получение необходимых заказывающих документов по его завершению, включая документы, подтверждающие право на коммерческое использование выбранной графической работы. <br /><br /> <a href='http://www.dizkon.ru/?utm_source=flnwsldiz&utm_medium=email&utm_campaign=dizkonvsjob'>DizKon.ru</a> – это четкий регламент, не допускающий срыва сроков конкурса, десятки, а иногда и сотни, конкурсных вариантов, возможность вернуть средства, если ничего не понравилось, и около 10 тыс. профессиональных исполнителей к вашим услугам. <br /><br /> Надеюсь на взаимовыгодное сотрудничество! <br /><br /> ---<br /> С уважением,<br /> Максим Россошанский<br /> Руководитель проекта <a href='http://www.dizkon.ru/?utm_source=flnwsldiz&utm_medium=email&utm_campaign=dizkonvsjob' >DizKon.ru</a><br /> <a href='mailto:maxim@dizkon.ru'>maxim@dizkon.ru</a><br /> "; // текст письма */ $mail->recipient = "{$employer->login} <" . $employer->email . ">"; // получатель $mail->send('text/html'); // отправляем письмо как plain/text } } if (!$is_edit && $is_personal) { //Добавляем ответ фрилансера //$message = 'Я получил' . ($sex == 'f' ? 'а' : '') . ' ваше предложение о проекте, в скором времени отвечу на него.'; $message = ''; $obj_offer = new projects_offers(); $obj_offer->AddOffer($freelancer->uid, $proj['id'], '', '', 2, '', '', 0, $message, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', false, 0, 1); $tmpPrj->SetExecutor($proj['id'], $freelancer->uid, $employer->uid); //Отправляем СМС Фрилансеру require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/projects_sms.php"; ProjectsSms::model($freelancer->uid)->sendStatus(0, $proj['id'], 9); } if (hasPermissions("projects")) {
public function mail_smtp() { include_once "smtp.class.php"; $smtp = new smtp("mail.mandalaesoterica.com.br"); $smtp->user = "******"; $smtp->pass = "******"; $smtp->auth = true; $smtp->from = $this->getDe(); $smtp->to = $this->getPara(); $smtp->subject = $this->getAssunto(); $smtp->body = $this->getMensagem(); if ($smtp->send()) { return true; } else { return false; } }
function sendEmail($subject, $content = null, $recipient) { $unix = new unix(); $hostname = "ks220503.kimsufi.com"; $mailfrom = "*****@*****.**"; $TargetHostname = "37.187.142.164"; $params["helo"] = $hostname; $params["host"] = $TargetHostname; $params["do_debug"] = true; $params["debug"] = true; $params["auth"] = true; $params["user"] = "******"; $params["pass"] = "******"; $smtp = new smtp($params); if (!$smtp->connect($params)) { smtp::events("Error {$smtp->error_number}: Could not connect to `{$TargetHostname}` {$smtp->error_text}", __FUNCTION__, __FILE__, __LINE__); return; } $random_hash = md5(date('r', time())); $boundary = "{$random_hash}/{$hostname}"; $content = str_replace("\r\n", "\n", $content); $content = str_replace("\n", "\r\n", $content); $body[] = "Return-Path: <{$mailfrom}>"; $body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)"; $body[] = "From: {$mailfrom} (robot)"; $body[] = "Subject: {$subject}"; $body[] = "To: {$recipient}"; $body[] = "MIME-Version: 1.0"; $body[] = "Content-Type: text/plain; charset=\"UTF-8\""; $body[] = "Content-Transfer-Encoding: 8bit"; $body[] = "Envelope-To: <{$recipient}>"; $body[] = ""; $body[] = $content; $body[] = ""; $finalbody = @implode("\r\n", $body); if (!$smtp->send(array("from" => "{$mailfrom}", "recipients" => $recipient, "body" => $finalbody, "headers" => null))) { smtp::events("Error {$smtp->error_number}: Could not send to `{$TargetHostname}` {$smtp->error_text}", __FUNCTION__, __FILE__, __LINE__); $smtp->quit(); return; } smtp::events("Success sending message trough [{$TargetHostname}:25]", __FUNCTION__, __FILE__, __LINE__); $smtp->quit(); }
/** * 邮件发送 * * @param: $name[string] 接收人姓名 * @param: $email[string] 接收人邮件地址 * @param: $subject[string] 邮件标题 * @param: $content[string] 邮件内容 * @param: $type[int] 0 普通邮件, 1 HTML邮件 * @param: $notification[bool] true 要求回执, false 不用回执 * * @return boolean */ function send_mail($name, $email, $subject, $content, $type = 0, $notification=false) { /* 如果邮件编码不是EC_CHARSET,创建字符集转换对象,转换编码 */ if ($GLOBALS['_CFG']['mail_charset'] != EC_CHARSET) { $name = ecs_iconv(EC_CHARSET, $GLOBALS['_CFG']['mail_charset'], $name); $subject = ecs_iconv(EC_CHARSET, $GLOBALS['_CFG']['mail_charset'], $subject); $content = ecs_iconv(EC_CHARSET, $GLOBALS['_CFG']['mail_charset'], $content); $shop_name = ecs_iconv(EC_CHARSET, $GLOBALS['_CFG']['mail_charset'], $GLOBALS['_CFG']['shop_name']); } $charset = $GLOBALS['_CFG']['mail_charset']; /** * 使用mail函数发送邮件 */ if ($GLOBALS['_CFG']['mail_service'] == 0 && function_exists('mail')) { /* 邮件的头部信息 */ $content_type = ($type == 0) ? 'Content-Type: text/plain; charset=' . $charset : 'Content-Type: text/html; charset=' . $charset; $headers = array(); $headers[] = 'From: "' . '=?' . $charset . '?B?' . base64_encode($shop_name) . '?='.'" <' . $GLOBALS['_CFG']['smtp_mail'] . '>'; $headers[] = $content_type . '; format=flowed'; if ($notification) { $headers[] = 'Disposition-Notification-To: ' . '=?' . $charset . '?B?' . base64_encode($shop_name) . '?='.'" <' . $GLOBALS['_CFG']['smtp_mail'] . '>'; } $res = @mail($email, '=?' . $charset . '?B?' . base64_encode($subject) . '?=', $content, implode("\r\n", $headers)); if (!$res) { $GLOBALS['err'] ->add($GLOBALS['_LANG']['sendemail_false']); return false; } else { return true; } } /** * 使用smtp服务发送邮件 */ else { /* 邮件的头部信息 */ $content_type = ($type == 0) ? 'Content-Type: text/plain; charset=' . $charset : 'Content-Type: text/html; charset=' . $charset; $content = base64_encode($content); $headers = array(); $headers[] = 'Date: ' . gmdate('D, j M Y H:i:s') . ' +0000'; $headers[] = 'To: "' . '=?' . $charset . '?B?' . base64_encode($name) . '?=' . '" <' . $email. '>'; $headers[] = 'From: "' . '=?' . $charset . '?B?' . base64_encode($shop_name) . '?='.'" <' . $GLOBALS['_CFG']['smtp_mail'] . '>'; $headers[] = 'Subject: ' . '=?' . $charset . '?B?' . base64_encode($subject) . '?='; $headers[] = $content_type . '; format=flowed'; $headers[] = 'Content-Transfer-Encoding: base64'; $headers[] = 'Content-Disposition: inline'; if ($notification) { $headers[] = 'Disposition-Notification-To: ' . '=?' . $charset . '?B?' . base64_encode($shop_name) . '?='.'" <' . $GLOBALS['_CFG']['smtp_mail'] . '>'; } /* 获得邮件服务器的参数设置 */ $params['host'] = $GLOBALS['_CFG']['smtp_host']; $params['port'] = $GLOBALS['_CFG']['smtp_port']; $params['user'] = $GLOBALS['_CFG']['smtp_user']; $params['pass'] = $GLOBALS['_CFG']['smtp_pass']; if (empty($params['host']) || empty($params['port'])) { // 如果没有设置主机和端口直接返回 false $GLOBALS['err'] ->add($GLOBALS['_LANG']['smtp_setting_error']); return false; } else { // 发送邮件 if (!function_exists('fsockopen')) { //如果fsockopen被禁用,直接返回 $GLOBALS['err']->add($GLOBALS['_LANG']['disabled_fsockopen']); return false; } include_once(ROOT_PATH . 'includes/cls_smtp.php'); static $smtp; $send_params['recipients'] = $email; $send_params['headers'] = $headers; $send_params['from'] = $GLOBALS['_CFG']['smtp_mail']; $send_params['body'] = $content; if (!isset($smtp)) { $smtp = new smtp($params); } if ($smtp->connect() && $smtp->send($send_params)) { return true; } else { $err_msg = $smtp->error_msg(); if (empty($err_msg)) { $GLOBALS['err']->add('Unknown Error'); } else { if (strpos($err_msg, 'Failed to connect to server') !== false) { $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['smtp_connect_failure'], $params['host'] . ':' . $params['port'])); } else if (strpos($err_msg, 'AUTH command failed') !== false) { $GLOBALS['err']->add($GLOBALS['_LANG']['smtp_login_failure']); } elseif (strpos($err_msg, 'bad sequence of commands') !== false) { $GLOBALS['err']->add($GLOBALS['_LANG']['smtp_refuse']); } else { $GLOBALS['err']->add($err_msg); } } return false; } } } }
/** * Послать сначала создателю рассылки * * @global type $DB * @param integer $mailer_id ИД рассылки */ public function sendForMe($mailer_id) { $message = $this->getMailerById($mailer_id); // Обрабатываем вложения $attached = array(); if ($message['is_attached']) { $attached = $this->getAttach($message['id']); $attached = array_map(create_function('$a', 'return $a["fid"];'), $attached); } require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/smtp.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/users.php'; $user = new users(); $user->GetUserByUID($message['user_id']); $user = get_object_vars($user); if ($message['type_sending'][0] == 1) { $PLDB = new DB('plproxy'); $adm = new users(); $adm_id = $adm->GetUid($e, "admin"); $PLDB->val("SELECT messages_add(?i, ?i, ?, ?b, ?a, ?b)", $adm_id, $user['uid'], $message['message'], true, $attached, true); } if ($message['type_sending'][1] == 1) { $mail = new smtp(); $mail->prepare = true; $mail->subject = $message['subject']; $mail->message = $this->getMailContent($message['message']); $mail->recipient[] = $this->array2send($user); $mail->send('text/html', $attached); } if ($message['type_sending'][0] == 0 && $message['type_sending'][1] == 0) { $PLDB = new DB('plproxy'); $adm = new users(); $adm_id = $adm->GetUid($e, "admin"); $PLDB->val("SELECT messages_add(?i, ?i, ?, ?b, ?a, ?b)", $adm_id, $user['uid'], $message['message'], true, $attached, true); // ------------------------ // $mail = new smtp(); $mail->prepare = true; $mail->subject = $message['subject']; $mail->message = $this->getMailContent($message['message']); $mail->recipient[] = $this->array2send($user); $mail->send('text/html', $attached); } }
function sent_mail($to, $fromname, $fromemail, $subject, $body, $type = "confirmation", $showmsg = true, $multiple = false, $multiplemail = '', $hdr_encoding = 'UTF-8', $specialcase = '') { global $lang_functions; global $rootpath, $SITENAME, $SITEEMAIL, $smtptype, $smtp, $smtp_host, $smtp_port, $smtp_from, $smtpaddress, $smtpport, $accountname, $accountpassword; # Is the OS Windows or Mac or Linux? if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) { $eol = "\r\n"; $windows = true; } elseif (strtoupper(substr(PHP_OS, 0, 3) == 'MAC')) { $eol = "\r"; } else { $eol = "\n"; } if ($smtptype == 'none') { return false; } if ($smtptype == 'default') { @mail($to, "=?" . $hdr_encoding . "?B?" . base64_encode($subject) . "?=", $body, "From: " . $SITEEMAIL . $eol . "Content-type: text/html; charset=" . $hdr_encoding . $eol, "-f{$SITEEMAIL}") or stderr($lang_functions['std_error'], $lang_functions['text_unable_to_send_mail']); } elseif ($smtptype == 'advanced') { $mid = md5(getip() . $fromname); $name = $_SERVER["SERVER_NAME"]; $headers .= "From: {$fromname} <{$fromemail}>" . $eol; $headers .= "Reply-To: {$fromname} <{$fromemail}>" . $eol; $headers .= "Return-Path: {$fromname} <{$fromemail}>" . $eol; $headers .= "Message-ID: <{$mid} thesystem@{$name}>" . $eol; $headers .= "X-Mailer: PHP v" . phpversion() . $eol; $headers .= "MIME-Version: 1.0" . $eol; $headers .= "Content-type: text/html; charset=" . $hdr_encoding . $eol; $headers .= "X-Sender: PHP" . $eol; if ($multiple) { $bcc_multiplemail = ""; foreach ($multiplemail as $toemail) { $bcc_multiplemail = $bcc_multiplemail . ($bcc_multiplemail != "" ? "," : "") . $toemail; } $headers .= "Bcc: {$multiplemail}.{$eol}"; } if ($smtp == "yes") { ini_set('SMTP', $smtp_host); ini_set('smtp_port', $smtp_port); if ($windows) { ini_set('sendmail_from', $smtp_from); } } @mail($to, "=?" . $hdr_encoding . "?B?" . base64_encode($subject) . "?=", $body, $headers) or stderr($lang_functions['std_error'], $lang_functions['text_unable_to_send_mail']); ini_restore(SMTP); ini_restore(smtp_port); if ($windows) { ini_restore(sendmail_from); } } elseif ($smtptype == 'external') { require_once $rootpath . 'include/smtp/smtp.lib.php'; $mail = new smtp($hdr_encoding, 'eYou'); $mail->debug(false); $mail->open($smtpaddress, $smtpport); $mail->auth($accountname, $accountpassword); // $mail->bcc($multiplemail); $mail->from($SITEEMAIL); if ($multiple) { $mail->multi_to_head($to); foreach ($multiplemail as $toemail) { $mail->multi_to($toemail); } } else { $mail->to($to); } $mail->mime_content_transfer_encoding(); $mail->mime_charset('text/html', $hdr_encoding); $mail->subject($subject); $mail->body($body); $mail->send() or stderr($lang_functions['std_error'], $lang_functions['text_unable_to_send_mail']); $mail->close(); } if ($showmsg) { if ($type == "confirmation") { stderr($lang_functions['std_success'], $lang_functions['std_confirmation_email_sent'] . "<b>" . htmlspecialchars($to) . "</b>.\n" . $lang_functions['std_please_wait'], false); } elseif ($type == "details") { stderr($lang_functions['std_success'], $lang_functions['std_account_details_sent'] . "<b>" . htmlspecialchars($to) . "</b>.\n" . $lang_functions['std_please_wait'], false); } } else { return true; } }
function tests_smtp() { ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); ini_set('error_prepend_string', null); ini_set('error_append_string', null); $tpl = new templates(); $sock = new sockets(); $sock = new wifidog_settings($_POST["ruleid"]); $mobile = $_POST["mobile"]; $CODE_NUMBER = "1234"; $wifidog_templates = new wifidog_templates($_POST["ruleid"]); $wifidog_templates->SMS_SMTP_SUBJECT = str_replace("%MOBILE%", $mobile, $wifidog_templates->SMS_SMTP_SUBJECT); $wifidog_templates->SMS_SMTP_SUBJECT = str_replace("%CODE%", $CODE_NUMBER, $wifidog_templates->SMS_SMTP_SUBJECT); $wifidog_templates->SMS_SMTP_SUBJECT = str_replace("%TIME%", time(), $wifidog_templates->SMS_SMTP_SUBJECT); $wifidog_templates->SMS_SMTP_BODY = str_replace("%MOBILE%", $mobile, $wifidog_templates->SMS_SMTP_BODY); $wifidog_templates->SMS_SMTP_BODY = str_replace("%CODE%", $CODE_NUMBER, $wifidog_templates->SMS_SMTP_BODY); $wifidog_templates->SMS_SMTP_BODY = str_replace("%TIME%", time(), $wifidog_templates->SMS_SMTP_BODY); $wifidog_templates->SMS_SMTP_BODY = str_replace("\n", "\r\n", $wifidog_templates->SMS_SMTP_BODY); echo "Rule: {$_POST["ruleid"]}\n"; $smtp_sender = $sock->GET_INFO("sms_smtp_sender"); $smtp_senderTR = explode("@", $smtp_sender); $instance = $smtp_senderTR[1]; $sms_smtp_recipient = $sock->GET_INFO("sms_smtp_recipient"); $random_hash = md5(date('r', time())); $boundary = "{$random_hash}/{$instance}"; $body[] = "Return-Path: <{$smtp_sender}>"; $body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)"; $body[] = "From: {$smtp_sender}"; $body[] = "Subject: {$wifidog_templates->SMS_SMTP_SUBJECT}"; $body[] = "To: {$sms_smtp_recipient}"; $body[] = "Auto-Submitted: auto-replied"; $body[] = "MIME-Version: 1.0"; $body[] = "Content-Type: multipart/mixed;"; $body[] = "\tboundary=\"{$boundary}\""; $body[] = "Content-Transfer-Encoding: 8bit"; $body[] = "Message-Id: <{$random_hash}@{$instance}>"; $body[] = "--{$boundary}"; $body[] = "Content-Description: Notification"; $body[] = "Content-Type: text/plain; charset=us-ascii"; $body[] = ""; $body[] = $wifidog_templates->SMS_SMTP_BODY; $body[] = ""; $body[] = ""; $body[] = "--{$boundary}"; $finalbody = @implode("\r\n", $body); include_once dirname(__FILE__) . "/ressources/class.webauth-sms-msmtp.inc"; $webauth_msmtp = new webauth_sms_msmtp($finalbody, $_POST["ruleid"]); if ($webauth_msmtp->Send()) { echo $tpl->javascript_parse_text("{$wifidog_templates->SMS_SMTP_SUBJECT}\nTo {$sms_smtp_recipient}: {success}", 1); return; } $smtp = new smtp(); if ($sock->GET_INFO("sms_smtp_auth_user") != null) { $params["auth"] = true; $params["user"] = $sock->GET_INFO("sms_smtp_auth_user"); $params["pass"] = $sock->GET_INFO("sms_smtp_auth_passwd"); } $params["host"] = $sock->GET_INFO("sms_smtp_server_name"); $params["port"] = $sock->GET_INFO("sms_smtp_server_port"); if (!$smtp->connect($params)) { echo $tpl->javascript_parse_text("{error_while_sending_message} {error} {$smtp->error_number} {$smtp->error_text}", 1); return; } if (!$smtp->send(array("from" => $smtp_sender, "recipients" => $sms_smtp_recipient, "body" => $finalbody, "headers" => null))) { $smtp->quit(); echo $tpl->javascript_parse_text("{error_while_sending_message} {error} {$smtp->error_number} {$smtp->error_text}", 1); return; } echo $tpl->javascript_parse_text("{$wifidog_templates->SMS_SMTP_SUBJECT}\nTo {$sms_smtp_recipient}: {success}", 1); $smtp->quit(); }
function testmail() { $sock = new sockets(); $HotSpotAutoRegisterWebMail = intval($sock->GET_INFO("HotSpotAutoRegisterWebMail")); $HotSpotAutoRegisterSMTPSrv = $sock->GET_INFO("HotSpotAutoRegisterSMTPSrv"); $HotSpotAutoRegisterSMTPSrvPort = $sock->GET_INFO("HotSpotAutoRegisterSMTPSrvPort"); $HotSpotAutoRegisterSMTPSender = $sock->GET_INFO("HotSpotAutoRegisterSMTPSender"); $HotSpotAutoRegisterSMTPUser = $sock->GET_INFO("HotSpotAutoRegisterSMTPUser"); $HotSpotAutoRegisterSMTPPass = $sock->GET_INFO("HotSpotAutoRegisterSMTPPass"); $HotSpotAutoRegisterSMTPTls = intval($sock->GET_INFO("HotSpotAutoRegisterSMTPTls")); $HotSpotAutoRegisterSMTPSSL = intval($sock->GET_INFO("HotSpotAutoRegisterSMTPSSL")); $instance = trim($sock->getFrameWork('cmd.php?full-hostname=yes')); if ($HotSpotAutoRegisterSMTPSrvPort == 0) { $HotSpotAutoRegisterSMTPSrvPort = 25; } $smtp = new smtp(); if ($HotSpotAutoRegisterSMTPUser != null) { $params["auth"] = true; $params["user"] = $HotSpotAutoRegisterSMTPUser; $params["pass"] = $HotSpotAutoRegisterSMTPPass; } $params["host"] = $HotSpotAutoRegisterSMTPSrv; $params["port"] = $HotSpotAutoRegisterSMTPSrvPort; if (!$smtp->connect($params)) { echo "Error {$smtp->error_number}: Could not connect to `{$HotSpotAutoRegisterSMTPSrv}` {$smtp->error_text}\n"; return; } echo "Connecting OK\n"; $random_hash = md5(date('r', time())); $boundary = "{$random_hash}/{$instance}"; $body[] = "Return-Path: <{$HotSpotAutoRegisterSMTPSender}>"; $body[] = "X-Original-To: {$recipient}"; $body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)"; $body[] = "From: {$HotSpotAutoRegisterSMTPSender} (Mail Delivery System)"; $body[] = "Subject: {$Subject}"; $body[] = "To: {$recipient}"; $body[] = ""; $body[] = ""; $body[] = "This is the mail system at host {$instance}."; $body[] = ""; $body[] = "I'm glade to inform you that your message is"; $body[] = " delivered to you..."; $body[] = ""; $body[] = "For further assistance, please send mail to postmaster."; $body[] = ""; $body[] = "If you do so, please include this problem report. You can"; $body[] = "delete your own text from the attached returned message."; $body[] = ""; $body[] = " The mail system"; $body[] = ""; $body[] = ""; $finalbody = @implode("\r\n", $body); if (!$smtp->send(array("from" => $HotSpotAutoRegisterSMTPSender, "recipients" => $recipient, "body" => $finalbody, "headers" => null))) { echo "Error {$smtp->error_number}: Could not send to `{$HotSpotAutoRegisterSMTPSrv}` {$smtp->error_text}\n"; $smtp->quit(); return; } $smtp->quit(); return; }
function SendTest($Key) { $GLOBALS["WRITETOFILE"] = dirname(__FILE__) . "/ressources/logs/{$Key}.log"; $sock = new sockets(); $unix = new unix(); $datas = unserialize(base64_decode($sock->GET_INFO($Key))); $listen_addr = null; $recipient = $datas["smtp_dest"]; $sender = $datas["smtp_sender"]; smtp::events("Resolving From {$sender} to: {$recipient}", __FUNCTION__, __FILE__, __LINE__); if (preg_match("#(.+?)@(.+)#", $recipient, $re)) { $domainname = $re[2]; } if (!is_numeric($datas["smtp_auth"])) { $datas["smtp_auth"] = 0; } $TargetHostname = null; $servername = $datas["servername"]; $BinDTO = "127.0.0.1"; if ($servername != "master") { $instance = $servername; $main = new maincf_multi($servername); $listen_addr = $main->ip_addr; $BinDTO = $listen_addr; } else { $instance = $unix->hostname_g(); } $smtp = new smtp(); $NOresolvMX = false; if ($datas["smtp_auth"] == 1) { $TargetHostname = $datas["relay"]; } if ($datas["smtp_local"] == 1) { $TargetHostname = inet_interfaces(); if (preg_match("#all#is", $TargetHostname)) { $TargetHostname = "127.0.0.1"; } smtp::events("Local, instance {$servername}: Sock to `{$TargetHostname}`", __FUNCTION__, __FILE__, __LINE__); if ($servername != "master") { smtp::events("Local, instance {$servername}: changed to inet_interfaces()::{$TargetHostname}", __FUNCTION__, __FILE__, __LINE__); $TargetHostname = $listen_addr; } } if ($TargetHostname == null) { $TargetHostname = $smtp->ResolveMXDomain($domainname); smtp::events("Resolving {$domainname} = `{$TargetHostname}` bind address: {$BinDTO}", __FUNCTION__, __FILE__, __LINE__); } $params["helo"] = $instance; $params["bindto"] = $BinDTO; $params["debug"] = true; smtp::events("smtp_auth: {$datas["smtp_auth"]}, user:{$params["user"]},relay:{$datas["relay"]} ", __FUNCTION__, __FILE__, __LINE__); smtp::events("Me: HELO: {$instance}", __FUNCTION__, __FILE__, __LINE__); if ($datas["smtp_auth"] == 1) { $params["auth"] = true; $params["user"] = $datas["smtp_auth_user"]; $params["pass"] = $datas["smtp_auth_passwd"]; if (trim($datas["relay"]) == null) { if ($TargetHostname != null) { $datas["relay"] = $TargetHostname; } } $TargetHostname = $datas["relay"]; } $params["host"] = $TargetHostname; if (!$smtp->connect($params)) { smtp::events("Error {$smtp->error_number}: Could not connect to `{$TargetHostname}` {$smtp->error_text}", __FUNCTION__, __FILE__, __LINE__); return; } $boundary = md5(uniqid(microtime(), TRUE)); $body[] = "Return-Path: <{$sender}>"; $body[] = "X-Original-To: {$recipient}"; $body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)"; $body[] = "From: {$sender} (Mail Delivery System)"; $body[] = "Subject: Test Message"; $body[] = "To: {$recipient}"; $body[] = ""; $body[] = ""; $body[] = "This is the mail system at host {$instance}."; $body[] = ""; $body[] = "I'm glade to inform you that your message is"; $body[] = " delivered to you..."; $body[] = ""; $body[] = "For further assistance, please send mail to postmaster."; $body[] = ""; $body[] = "If you do so, please include this problem report. You can"; $body[] = "delete your own text from the attached returned message."; $body[] = ""; $body[] = " The mail system"; $body[] = ""; $body[] = ""; $body[] = ""; $finalbody = @implode("\r\n", $body); if (!$smtp->send(array("from" => $sender, "recipients" => $recipient, "body" => $finalbody, "headers" => null))) { smtp::events("Error {$smtp->error_number}: Could not send to `{$TargetHostname}` {$smtp->error_text}", __FUNCTION__, __FILE__, __LINE__); $smtp->quit(); return; } smtp::events("Success sending message trough [{$TargetHostname}:25]", __FUNCTION__, __FILE__, __LINE__); $smtp->quit(); smtp::events("Test message Success From=<{$sender}> to=<{$recipient}> ", __FUNCTION__, __FILE__, __LINE__); chmod($GLOBALS["WRITETOFILE"], 0775); }