本文整理汇总了PHP中smtp::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP smtp::connect方法的具体用法?PHP smtp::connect怎么用?PHP smtp::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类smtp
的用法示例。
在下文中一共展示了smtp::connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function &connect($params = array())
{
if (!isset($this->status))
{
$obj = new smtp($params);
if ($obj->connect())
$obj->status = SMTP_STATUS_CONNECTED;
return $obj;
}
else
{
$this->connection = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
if (function_exists('socket_set_timeout'))
@socket_set_timeout($this->connection, 5, 0);
$greeting = $this->get_data();
if (is_resource($this->connection))
return $this->auth ? $this->ehlo() : $this->helo();
else
{
$this->errors[] = 'Failed to connect to server: ' . $errstr;
return false;
}
}
}
示例2: connect
function connect($params = array())
{
if (!isset($this->status)) {
$obj = new smtp($params);
if ($obj->connect()) {
$obj->status = SMTP_STATUS_CONNECTED;
}
return $obj;
} else {
if (!empty($GLOBALS['_CFG']['smtp_ssl'])) {
$this->host = "ssl://" . $this->host;
}
$this->connection = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
if ($this->connection === false) {
$this->errors[] = 'Access is denied.';
return false;
}
@socket_set_timeout($this->connection, 0, 250000);
$greeting = $this->get_data();
if (is_resource($this->connection)) {
$this->status = 2;
return $this->auth ? $this->ehlo() : $this->helo();
} else {
log_write($errstr, __FILE__, __LINE__);
$this->errors[] = 'Failed to connect to server: ' . $errstr;
return false;
}
}
}
示例3: SEND_MAIL
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);
}
示例4: mailIt
function mailIt($htmltosend, $emailto = '', $emailfrom = '', $emailsubj = '', $attachment = '')
{
global $system;
include_once 'class.smtp.inc';
include_once 'class.html.mime.mail.inc';
include_once 'mimePart.php';
define('CRLF', "\r\n", TRUE);
$mail = new html_mime_mail(array('X-Mailer: Html Mime Mail Class'));
if ($attachment != '') {
$mail->add_attachment($attachment, 'ordine.csv', 'application/csv');
//metti un nome e un mime type a piacimento, secondo quel che vuoi
}
$mail->add_html($htmltosend, $emailsubj);
if (!$mail->build_message()) {
exit('Failed to build email');
}
$params = array('host' => '65.125.231.122', 'port' => 25, 'helo' => 'localhost', 'auth' => FALSE, 'user' => '', 'pass' => '');
$smtp =& smtp::connect($params);
$send_params = array('from' => $emailfrom, 'recipients' => array($emailto), 'headers' => array('From: ' . $system->SETTINGS['sitename'] . ' <' . $emailfrom . '>', 'To: ' . $emailto . '', 'Subject: ' . $emailsubj));
$mail->smtp_send($smtp, $send_params);
}
示例5: SendTest
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__);
//.........这里部分代码省略.........
示例6: testmail
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;
}
示例7: wifidog_register_perform
//.........这里部分代码省略.........
$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}");
}
示例8: wifidog_register_perform
//.........这里部分代码省略.........
}
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}");
}
示例9: sendtestmail
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";
}
示例10: sendemail
function sendemail($email, $name, $vars, $page = 0)
{
global $useSMTP, $smtp_server, $smtp_helo, $smtp_uname, $smtp_pword, $mailer_id;
global $email_from, $reply_to, $friendly_name, $thisUrl;
//$emailSubj = sprintf("Can you become a Master in self-control %s?", $vars['firstname']);
include_once AFGPATH . '/includes/class.html.mime.mail.inc';
define('CRLF', "\r\n", TRUE);
$mail = new html_mime_mail(array("X-Mailer: {$mailer_id}"));
if ($smtp_uname != "" || $smtp_pword != "") {
$smtpauth = TRUE;
} else {
$smtpauth = FALSE;
}
if (CODEDEBUG) {
//file_put_contents(AFGPATH.'/file.log', AFGPATH.'/'.$vars['email'].'.txt'.AFGPATH.'/'.$vars['email'].'.html', FILE_APPEND);
}
if (file_exists(AFGPATH . '/' . $vars['email'] . '.txt') && file_exists(AFGPATH . '/' . $vars['email'] . '.html')) {
$email_body = fread($fp = fopen(AFGPATH . '/' . $vars['email'] . '.txt', 'r'), filesize(AFGPATH . '/' . $vars['email'] . '.txt'));
fclose($fp);
$html_email_body = fread($fp = fopen(AFGPATH . '/' . $vars['email'] . '.html', 'r'), filesize(AFGPATH . '/' . $vars['email'] . '.html'));
fclose($fp);
foreach ($vars as $key => $val) {
if (strpos($email_body, '[' . trim($key) . ']')) {
$email_body = preg_replace("/\\[{$key}\\]/", stripslashes($val), $email_body);
}
}
$email_body = preg_replace('/\\[(\\S.*?)\\]/', '', $email_body);
if ($html_email_body) {
foreach ($vars as $key => $val) {
if (strpos($html_email_body, '[' . trim($key) . ']')) {
$html_email_body = preg_replace("/\\[{$key}\\]/", stripslashes($val), $html_email_body);
}
}
$html_email_body = preg_replace('/\\[(\\S.*?)\\]/', '', $html_email_body);
$mail->add_html($html_email_body, $email_body, AFGPATH . '/emails/');
//$mail->add_html($html_email_body, $email_body, 'img');
} else {
$mail->add_text($email_body);
}
$mail->build_message();
$subject = '';
if ($vars['email'] == 'emails/email-thankyou') {
$subject = 'Thank you';
}
if ($vars['email'] == 'emails/email-thankyou2') {
$subject = 'Thank you';
}
if ($vars['email'] == 'emails/email-flag') {
$subject = 'Flagged image';
}
$headers = array("From: \"{$friendly_name}\" <{$email_from}>", "To: \"{$name}\" <{$email}>", "Subject: " . $subject, "Reply-To: {$reply_to}");
if ($useSMTP) {
include_once AFGPATH . '/includes/class.smtp.inc';
$params = array('host' => $smtp_server, 'port' => 25, 'helo' => $smtp_helo, 'auth' => $smtpauth, 'user' => $smtp_uname, 'pass' => $smtp_pword);
//echo '<PRE>'.htmlentities($mail->get_rfc822($name, $email, $friendly_name, $email_from, $email_subj, $headers)).'</PRE>';
$smtp =& smtp::connect($params);
$send_params = array('from' => $email_from, 'recipients' => $email, 'headers' => $headers);
$mail->smtp_send($smtp, $send_params);
} else {
$mail->send($name, $email, $friendly_name, $email_from, $emailSubj, $headers);
}
/*
if (CODEDEBUG){
$content = print_r(htmlentities($mail->get_rfc822($name, $email, $friendly_name, $email_from, $email_subj, $headers)), true);
file_put_contents(AFGPATH.'/file.log', $content, FILE_APPEND);
}
*/
}
}
示例11: tests_smtp
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();
}
示例12: ufdb_smtp
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");
}
}
示例13: tests_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();
}
示例14: send_mail
/**
* Óʼþ·¢ËÍ.
*
* @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;
}
//.........这里部分代码省略.........
示例15: array
if ($prefs['zend_mail_handler'] == 'smtp') {
$params = array();
$params["host"] = $prefs['zend_mail_smtp_server'];
$params["port"] = $prefs['zend_mail_smtp_port'];
$params["helo"] = $prefs['zend_mail_smtp_helo'];
$params["user"] = $prefs['zend_mail_smtp_user'];
$params["pass"] = $prefs['zend_mail_smtp_pass'];
$params["security"] = $prefs['zend_mail_smtp_security'];
if ($prefs['zend_mail_smtp_auth'] == 'login') {
$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);