国内精品欧美视频一区二区,成年人网站一级黄色免费,欧美一区二区三区不卡放荡的寡妇,欧美成人性生活视频在线观看

中山php|最優(yōu)網(wǎng)絡(luò)中山做網(wǎng)站 中山php建站

最優(yōu)良人

2011/08/24 at 23:53

php在windows主機(jī)或虛擬空間利用socket在線發(fā)送郵件

在linux虛擬主機(jī)下一般可以利用php的mail函數(shù)直接發(fā)郵件
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

但是在windows虛擬主機(jī)下則不能直接使用mail函數(shù),可以通過(guò)socket了,采用郵箱的smtp服務(wù)在線發(fā)送郵件(現(xiàn)在的163免費(fèi)郵箱一注冊(cè)就可以免費(fèi)使用這個(gè)服務(wù),并且默認(rèn)開(kāi)通的),比較成熟的在線發(fā)送郵件類有php_mailer,功能很強(qiáng)大,不過(guò)下面介紹的是一個(gè)比較簡(jiǎn)單的socket郵件發(fā)送類,應(yīng)付一般的需求足夠了。

使用方法是:

require_once (dirname(__FILE__).'/email.class.php');//該類的代碼附在文章后面
//##########################################
$smtpserver = "smtp.163.com";//SMTP服務(wù)器
$smtpserverport =25;//SMTP服務(wù)器端口
$smtpusermail = "XXX@163.com";//SMTP服務(wù)器的用戶郵箱
$smtpemailto = "XXXXX@qq.com";//發(fā)送給誰(shuí)
$smtpuser = "s_XXX";//SMTP服務(wù)器的用戶帳號(hào)
$smtppass = "aaa123456";//SMTP服務(wù)器的用戶密碼
$mailsubject = "收到用戶的產(chǎn)品詢價(jià)";//郵件主題
$mailbody = "用戶提交了產(chǎn)品詢價(jià),請(qǐng)登錄網(wǎng)站后臺(tái)查看!";//郵件內(nèi)容
$mailtype = "HTML";//郵件格式(HTML/TXT),TXT為文本郵件
//##########################################
$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);//這里面的一個(gè)true是表示使用身份驗(yàn)證,否則不使用身份驗(yàn)證.
$smtp->debug = false;//是否顯示發(fā)送的調(diào)試信息
$smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype);

附簡(jiǎn)單的郵件發(fā)送類代碼

<?
class smtp
{
/* Public Variables */
var $smtp_port;
var $time_out;
var $host_name;
var $log_file;
var $relay_host;
var $debug;
var $auth;
var $user;
var $pass;

/* Private Variables */
var $sock;

/* Constractor */
function smtp($relay_host = "", $smtp_port = 25,$auth = false,$user,$pass)
{
$this->debug = FALSE;
$this->smtp_port = $smtp_port;
$this->relay_host = $relay_host;
$this->time_out = 30; //is used in fsockopen()
#
$this->auth = $auth;//auth
$this->user = $user;
$this->pass = $pass;
#
$this->host_name = "localhost"; //is used in HELO command
$this->log_file ="";

$this->sock = FALSE;
}

/* Main Function */
function sendmail($to, $from, $subject = "", $body = "", $mailtype, $cc = "", $bcc = "", $additional_headers = "")
{
$mail_from = $this->get_address($this->strip_comment($from));
$body = ereg_replace("(^|(\r\n))(\\.)", "\\1.\\3", $body);
$header .= "MIME-Version:1.0\r\n";
if($mailtype=="HTML"){
$header .= "Content-Type:text/html\r\n";
}
$header .= "To: ".$to."\r\n";
if ($cc != "") {
$header .= "Cc: ".$cc."\r\n";
}
$header .= "From: $from<".$from.">\r\n";
$header .= "Subject: ".$subject."\r\n";
$header .= $additional_headers;
$header .= "Date: ".date("r")."\r\n";
$header .= "X-Mailer:By Redhat (PHP/".phpversion().")\r\n";
list($msec, $sec) = explode(" ", microtime());
$header .= "Message-ID: <".date("YmdHis", $sec).".".($msec*1000000).".".$mail_from.">\r\n";
$TO = explode(",", $this->strip_comment($to));

if ($cc != "") {
$TO = array_merge($TO, explode(",", $this->strip_comment($cc)));
}

if ($bcc != "") {
$TO = array_merge($TO, explode(",", $this->strip_comment($bcc)));
}

$sent = TRUE;
foreach ($TO as $rcpt_to) {
$rcpt_to = $this->get_address($rcpt_to);
if (!$this->smtp_sockopen($rcpt_to)) {
$this->log_write("Error: Cannot send email to ".$rcpt_to."\n");
$sent = FALSE;
continue;
}
if ($this->smtp_send($this->host_name, $mail_from, $rcpt_to, $header, $body)) {
$this->log_write("E-mail has been sent to <".$rcpt_to.">\n");
} else {
$this->log_write("Error: Cannot send email to <".$rcpt_to.">\n");
$sent = FALSE;
}
fclose($this->sock);
$this->log_write("Disconnected from remote host\n");
}
//echo "<br>";
//echo $header;
return $sent;
}

/* Private Functions */

function smtp_send($helo, $from, $to, $header, $body = "")
{
if (!$this->smtp_putcmd("HELO", $helo)) {
return $this->smtp_error("sending HELO command");
}
#auth
if($this->auth){
if (!$this->smtp_putcmd("AUTH LOGIN", base64_encode($this->user))) {
return $this->smtp_error("sending HELO command");
}

if (!$this->smtp_putcmd("", base64_encode($this->pass))) {
return $this->smtp_error("sending HELO command");
}
}
#
if (!$this->smtp_putcmd("MAIL", "FROM:<".$from.">")) {
return $this->smtp_error("sending MAIL FROM command");
}

if (!$this->smtp_putcmd("RCPT", "TO:<".$to.">")) {
return $this->smtp_error("sending RCPT TO command");
}

if (!$this->smtp_putcmd("DATA")) {
return $this->smtp_error("sending DATA command");
}

if (!$this->smtp_message($header, $body)) {
return $this->smtp_error("sending message");
}

if (!$this->smtp_eom()) {
return $this->smtp_error("sending <CR><LF>.<CR><LF> [EOM]");
}

if (!$this->smtp_putcmd("QUIT")) {
return $this->smtp_error("sending QUIT command");
}

return TRUE;
}

function smtp_sockopen($address)
{
if ($this->relay_host == "") {
return $this->smtp_sockopen_mx($address);
} else {
return $this->smtp_sockopen_relay();
}
}

function smtp_sockopen_relay()
{
$this->log_write("Trying to ".$this->relay_host.":".$this->smtp_port."\n");
$this->sock = @fsockopen($this->relay_host, $this->smtp_port, $errno, $errstr, $this->time_out);
if (!($this->sock && $this->smtp_ok())) {
$this->log_write("Error: Cannot connenct to relay host ".$this->relay_host."\n");
$this->log_write("Error: ".$errstr." (".$errno.")\n");
return FALSE;
}
$this->log_write("Connected to relay host ".$this->relay_host."\n");
return TRUE;;
}

function smtp_sockopen_mx($address)
{
$domain = ereg_replace("^.+@([^@]+)$", "\\1", $address);
if (!@getmxrr($domain, $MXHOSTS)) {
$this->log_write("Error: Cannot resolve MX \"".$domain."\"\n");
return FALSE;
}
foreach ($MXHOSTS as $host) {
$this->log_write("Trying to ".$host.":".$this->smtp_port."\n");
$this->sock = @fsockopen($host, $this->smtp_port, $errno, $errstr, $this->time_out);
if (!($this->sock && $this->smtp_ok())) {
$this->log_write("Warning: Cannot connect to mx host ".$host."\n");
$this->log_write("Error: ".$errstr." (".$errno.")\n");
continue;
}
$this->log_write("Connected to mx host ".$host."\n");
return TRUE;
}
$this->log_write("Error: Cannot connect to any mx hosts (".implode(", ", $MXHOSTS).")\n");
return FALSE;
}

function smtp_message($header, $body)
{
fputs($this->sock, $header."\r\n".$body);
$this->smtp_debug("> ".str_replace("\r\n", "\n"."> ", $header."\n> ".$body."\n> "));

return TRUE;
}

function smtp_eom()
{
fputs($this->sock, "\r\n.\r\n");
$this->smtp_debug(". [EOM]\n");

return $this->smtp_ok();
}

function smtp_ok()
{
$response = str_replace("\r\n", "", fgets($this->sock, 512));
$this->smtp_debug($response."\n");

if (!ereg("^[23]", $response)) {
fputs($this->sock, "QUIT\r\n");
fgets($this->sock, 512);
$this->log_write("Error: Remote host returned \"".$response."\"\n");
return FALSE;
}
return TRUE;
}

function smtp_putcmd($cmd, $arg = "")
{
if ($arg != "") {
if($cmd=="") $cmd = $arg;
else $cmd = $cmd." ".$arg;
}

fputs($this->sock, $cmd."\r\n");
$this->smtp_debug("> ".$cmd."\n");

return $this->smtp_ok();
}

function smtp_error($string)
{
$this->log_write("Error: Error occurred while ".$string.".\n");
return FALSE;
}

function log_write($message)
{
$this->smtp_debug($message);

if ($this->log_file == "") {
return TRUE;
}

$message = date("M d H:i:s ").get_current_user()."[".getmypid()."]: ".$message;
if (!@file_exists($this->log_file) || !($fp = @fopen($this->log_file, "a"))) {
$this->smtp_debug("Warning: Cannot open log file \"".$this->log_file."\"\n");
return FALSE;
}
flock($fp, LOCK_EX);
fputs($fp, $message);
fclose($fp);

return TRUE;
}

function strip_comment($address)
{
$comment = "\\([^()]*\\)";
while (ereg($comment, $address)) {
$address = ereg_replace($comment, "", $address);
}

return $address;
}

function get_address($address)
{
$address = ereg_replace("([ \t\r\n])+", "", $address);
$address = ereg_replace("^.*<(.+)>.*$", "\\1", $address);

return $address;
}

function smtp_debug($message)
{
if ($this->debug) {
echo $message."<br>";
}
}

function get_attach_type($image_tag) { //

$filedata = array();

$img_file_con=fopen($image_tag,"r");
unset($image_data);
while ($tem_buffer=AddSlashes(fread($img_file_con,filesize($image_tag))))
$image_data.=$tem_buffer;
fclose($img_file_con);

$filedata['context'] = $image_data;
$filedata['filename']= basename($image_tag);
$extension=substr($image_tag,strrpos($image_tag,"."),strlen($image_tag)-strrpos($image_tag,"."));
switch($extension){
case ".gif":
$filedata['type'] = "image/gif";
break;
case ".gz":
$filedata['type'] = "application/x-gzip";
break;
case ".htm":
$filedata['type'] = "text/html";
break;
case ".html":
$filedata['type'] = "text/html";
break;
case ".jpg":
$filedata['type'] = "image/jpeg";
break;
case ".tar":
$filedata['type'] = "application/x-tar";
break;
case ".txt":
$filedata['type'] = "text/plain";
break;
case ".zip":
$filedata['type'] = "application/zip";
break;
default:
$filedata['type'] = "application/octet-stream";
break;
}
return $filedata;
}

}
?>

標(biāo)簽:,
-
国产成人啪午夜精品网站-国产乱码精品一区二区三区-男人天堂网av一区二区三区四区-亚洲第一区二区精品三区在线| 熟妇久久人妻中文字幕-国产精品久久久久精品三级人-亚洲蜜臀人妻中文字幕-国产一区二区内部视频| 国产熟女露脸91麻豆-自拍视频在线观看后入-麻豆映画视频在线观看-国产视频男女在线观看| 少妇高潮真爽在线观看-韩国福利视频一区二区三区-警花av一区二区三区-尤物视频国产在线观看| 日韩午夜精品免费视频-真实国产精品自拍视频-91麻豆精产国品一二区灌醉-一本色道久久综合亚洲精品东京热| 亚洲精品国产精品乱码不-亚洲天堂精品自拍偷拍-风骚少妇久久精品在线观看-一区二区在线观看视频在线观看| 欧美性色婷婷久久久精品-久久这里只有精品国产宅男av-久久男女爱爱视频免费观看-另类福利亚洲丝袜激情在线| 久久精品国产亚洲av麻豆甜-蜜桃亚洲精品一区二区三区-国产成a人亚洲精品无v码-午夜一区精品国产亚洲av| 加勒比中文字幕久久av-久久黄色美女三级久一点黄-国产精品无套高潮久久-久久婷婷综合色拍亚洲| 成年人有性生活正常吗-亚洲熟女熟妇五十路熟女熟妇-亚洲精品一区二区高清在线-日本视频在线播放91| 日韩精品中文字幕人妻一区-国产免费午夜福利一区二区-亚洲国产精品久久亚洲精品-亚洲伦理一区二区三区中文| 亚洲国产国语对白在线视频-中文字幕中文字字幕码一区二区-毛片av在线免费观看-免费在线观看av毛片| 黑人精品视频一区二区三区-在线播放免费av大片-在线免费观看日韩精品-日本av在线观看一区二区三区| 极品尤物高颜值女神露脸-免费视频一区二区三区美女-麻豆av国语对白麻豆-亚洲精品国产午夜精品| 美女福利视频一区二区-在线观看你懂的日韩精品亚洲-男女丁丁一进一出视频-蜜臀av一区二区三区精品人妻| 九九热视频这里免费看-一二三区无线乱码中文在线-粉嫩美女无套内射视频免费播放-国产麻豆一精品一男同| 口爆调教视频在线播放-一区二区三区中文字幕自拍偷拍-亚洲精品乱码免费精品乱码免费-国产精品日韩欧美高清情| 亚洲少妇插进去综合网-久草免费在线人妻视频-丰满人妻熟妇乱精品视频-日韩极品精品视频免费在线观看| 午夜av毛片在线观看-青草精品视频在线观看-亚洲av中文字字幕乱码综合-午夜av一区二区三区中文字幕| 久久精品国产久精国产爱-久久超碰97中文字幕-久热这里只有精品视频一区-日韩av在线免费观看| 亚洲成人av综合在线-日韩精品久久久中文字幕人妻-国产精品无套白嫩剧情-五月婷婷久久激情综合| 偷拍日韩女生厕所尿尿-水蜜桃一区二区三区四区-亚洲成人色黄网站久久-久久久国产综合午夜精品| 少妇人妻上班偷人露脸-欧美中文字幕乱码视频-欧美韩日本一本交道免费-国产一区,二区,三区免费视频| 成人国产精品一区二区香蕉-一区二区三区欧美日韩电影在线观看-午夜福利视频合集一区二区-人妻少妇被粗大爽在线| 亚洲中文成人乱码在线-国产一区二区三区久久综合-成人在线观看免费国产视频-一区二区水蜜桃视频在线观看| 99久久国产自偷自自偷蜜月-日韩熟女激情中文字幕-亚洲狼人社区av在线观看-四虎成人精品国产永久| 午夜视频在线观看色诱-久久精品午夜福利视频-熟妇人妻av一区二区三区-一区二区三区中文字幕在线观看| 狠狠做深爱婷婷丁香综合-成人日韩亚洲在线观看-蜜桃传媒mv在线免费-国产日韩入口一区二区| a在线观看视频在线播放-81精品人妻一区二区三区蜜桃-国产午夜福利片一级做-在线观看亚洲视频一区二区| 人妻少妇精品久久中文字幕-在线免费观看亚洲小视频-网友偷拍视频一区二区三区-亚洲国产精品日韩av在线| 日本岛国三级黄色录像-日韩久久成人免费电影-中文字幕日韩专区一区二区-国产成人大片在线播放| 日本一区二区三区欧美精品-农村少妇真人毛片视频-亚洲av乱码专区国产乱码-跨年夜爆操极品翘臀日韩| 尤物视频在线观看精品-日韩午夜男女爽爽影院-日本少妇下面好紧水多影片-国产亚洲精品视频在线网| 久久精品国产亚洲av麻豆看片-内射后入高潮在线视频-亚洲精品一区三区三区在线-亚洲乱码一区二区三区视色| 成年深夜在线观看视频-成人国产av精品在线-av乱亚洲一区二区三区-亚洲精品综合一区二区在线| 精品人妻中文字幕有码在线-亚洲欧美一区二区成人精品久久久-亚洲第一人伊狼人久久-亚洲国产欧美精品在线观看| 国产精品乱码一区二区三区-亚洲国产日本不卡一卡-日韩av手机免费网站-国产精品日韩在线亚洲一区| 中文字幕在线成人大片-日本一区二区在线视频播放-精品在线亚洲一区二区三区-在线免费观看播放视频| 男人的精品天堂一区二区在线观看-婷婷久久香蕉毛片毛片-久久视频在线观看夫妻-亚洲国产一区久久yourpan| 色和尚在线视频久天天-少妇高潮太爽了在线免费观看-伊人久久大香线蕉午夜av一区-亚洲国产精品不伦不卡| 九九热久久这里有精品视频-2020亚洲欧美日韩在线-国产精品久久无遮挡影片-亚洲国产高清在线不卡|