亚洲人成电影在线观看天堂色,国产三级国产精品国产专区50 http://m.jartj.cn/blog 中山php|最優(yōu)網(wǎng)絡(luò) Mon, 13 May 2013 04:56:43 +0000 en hourly 1 http://wordpress.org/?v=3.1.4 php在windows主機(jī)或虛擬空間利用socket在線發(fā)送郵件 http://m.jartj.cn/blog/view-167.html http://m.jartj.cn/blog/view-167.html#comments Wed, 24 Aug 2011 15:53:25 +0000 lin http://m.jartj.cn/blog/?p=167 在linux虛擬主機(jī)下一般可以利用php的mail函數(shù)直接發(fā)郵件
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

但是在windows虛擬主機(jī)下則不能直接使用mail函數(shù),可以通過socket了,采用郵箱的smtp服務(wù)在線發(fā)送郵件(現(xiàn)在的163免費(fèi)郵箱一注冊(cè)就可以免費(fèi)使用這個(gè)服務(wù),并且默認(rèn)開通的),比較成熟的在線發(fā)送郵件類有php_mailer,功能很強(qiáng)大,不過下面介紹的是一個(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ā)送給誰
$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;
}

}
?>

]]>
http://m.jartj.cn/blog/view-167.html/feed 2688
国产老熟女乱子一区二区-欧美日本中国一区二区-欧美日韩国产午夜精品-青青草视频在线观看入口| 日韩熟女av在线观看-中文字幕人妻丝祙乱一区三区-亚洲国产精品第一区二区三区-欧美制服丝袜一区二区三区| 国产成人综合激情婷婷-亚洲国产综合在线观看不卡-色综网久久天天综合狼人-亚洲av高清在线不卡| 国产熟女老阿姨毛片看爽爽-精品少妇人妻久久免费-韩国午夜福利片在线观看-西川结衣在线中文字幕| 女同在线播放中文字幕-国产成人亚洲精品在线看-日韩有码在线观看视频-蜜桃av噜噜一区二区三区视频| 一本久道视频无线视频试看-亚洲国产精品一区二区三区久久-中文字幕色偷偷人妻久久-久久精品99国产精品中| 女人高潮久久久久久久久-久久久国产熟女一区二区三区-91在线精品国产丝袜-国产精品日韩亚洲一区二区| 日韩三级一区二区三区高清-亚洲插入视频在线观看-91精品中文字幕一区二区三区-精品一区二区三区男人吃奶视频| 国内自拍精品视频在线-欧美黑人巨大一区二区三区-中文字幕日韩精品人妻-婷婷激情五月天中文字幕| 99久久亚洲综合网精品-久久热福利视频在线观看-日韩av人妻中文字幕-日本一区二区三区视频在线播放| 精品国产亚洲av蜜臀-欧美亚洲伦理在线视频-久久亚洲国产成人影院av-国产精品99蜜臀久久不卡二区| 国产自拍在线视频免费观看-精品午夜福利一区二区三区-日韩av在线免费观看毛片-国产三级黄色片在线观看| 网站视频精品一区二区在线观看-中文有码中文字幕免费视频-99热这里有精品久久-日韩av在线高清免费观看| 日本激情内射亚洲精品-国产亚洲一区二区三区午夜-国产精品人妻熟女av在线-亚洲av综合亚洲精品| 传媒精品视频在线观看-久久蜜汁成人国产精品-国产精品伦理视频一区三区-丰满少妇特黄一区二区三区| 中文中国女厕偷拍视频-男人天堂亚洲天堂av-精品国产一区二区三区香蕉蜜臂-国产亚洲日本精品成人专区| 极品尤物高颜值女神露脸-免费视频一区二区三区美女-麻豆av国语对白麻豆-亚洲精品国产午夜精品| 国产精品第五页在线观看-亚洲欧美日韩丝袜另类一区-国产懂色av一区二区三区-午夜亚洲欧美日韩在线| 亚洲视频在线观看第一页-精品偷拍另类欧美日韩-日韩高清在线一区二区三区-久久天天操狠狠操夜夜av| 午夜福利网午夜福利网-国产粉嫩学生在线观看-亚洲精品成人高清在线观看-亚洲人成人日韩中文字幕| 国产女主播在线播放福利-日韩中文字幕综合第二页-av男人的天堂免费观看-国产乱码免费一区二区三区不卡| 成熟女人毛茸茸的免费视频-91麻豆精品国产自产在线游戏-国产男女猛烈无遮挡免费视频-一级黄片国产精品久久| 草草草草伦理少妇高清-国内精品视频网站草草-国产精品精国产在线观看-国产麻豆激情av在线| 麻豆免费播放在线观看-在线观看成人午夜福利-亚洲华人在线免费视频-国产极品超大美女白嫩在线| 国产精品性色av免费-人妻系列中文字幕一区二区-精品一区二区三区在线日韩-亚洲欧美日韩国产一二三区| 日本一区二区三区黄色网-亚洲国产综合久久天堂-精品国产乱码久久蜜桃-欧美少妇精品在线观看| 久久久精品国产亚洲av高清涩受-国产精品一区二区三区成人-欧美日韩国产精品视频一区二区三区-大陆美女阴户特写毛片| 国产精品中文字幕在线一区-国产成人美女精品自在拍av-密桃av一区二区三区四区-女优免费中文字幕在线| 加勒比中文字幕久久av-久久黄色美女三级久一点黄-国产精品无套高潮久久-久久婷婷综合色拍亚洲| 免费十八禁一区二区三区-国产精品一区二区三区99-在线一区二区三区男男视频观看-精品欧美一区二区三区人妖| 蜜桃臀欧美日韩国产精品-最近欧美日韩一区二区-亚洲综合成人一区二区三区-免费五十路熟妇在线视频| 亚欧曰中文字幕av一区二区三区-最新国产情侣在线视频-黄片大全视频免费在线观看-久久超级碰碰碰一区二区三区| 亚洲国内精品一区二区在线-亚洲国产成人精品青青草原-精品在线视频免费在线观看视频-亚洲美女激情福利在线| 日韩欧美国产亚洲中文-亚洲国产av第一福利网-亚洲欧洲日韩一区二区三区-91精品国产福利线观看久久| 日本高清不卡一区二区三区-男女国产猛烈无遮挡色-精品九九热在线免费视频-日本一区二区福利在线观看| 国产成人午夜精品久久-91久久精品一区二区喷水喷白浆-中文字幕日本人妻99-美女人妻少妇一区二区三区| 开心五月激情五月综合-国产88精品久久久久久-乱人伦精品视频在线观看-秘社一区二区三区一午夜日本| 国产免费福利在线激情视频-自拍偷拍福利视频在线-国产亚洲一区二区三区在线播放-欧美国产日本高清不卡免费| 无套进入极品美女少妇-新久久久高清黄色国产-国产肥臀在线精品一区二区-深夜午夜福利在线观看| 青草精品在线视频观看-色呦呦在线观看中文字幕-国产一区二区日本在线观看-草青青在线视频免费观看| 国产精品乱码一区二区三区视频-国产自拍精品在线一区二区-五月综合丁香婷婷久久-在线国产精品一区二区三区|