未分类

【www.2979.com】能够更加好的施用满意平日网上朋友建站须要,邮件大旨’

27 4月 , 2020  

使用php直接展开socket端口实行发信的小程序特点是应用smtp认证,能够更加好的利用满意经常网上老铁建站须求。

if(send_mail(‘test@qq.com’,’邮件宗旨’,’邮件内容’State of Qatar==””卡塔尔(قطر‎{
echo “发送成功!<br>”;
} else{
echo “发送失利!<br>”;
}

总体源码附在本文中,同样内容可到下列地点下载。转发请申明出处。

<?php
$to = “test@test.com”;
$subject = “Test Subject”;
$message = “This is the test email.”;
$from = “youremail@yourdomain.com”;
$headers = “From: $from”;
mail($to,$subject,$message,$headers);
?>

 <?php
function send_mail($to, $subject = ‘No subject’, $body) {
$loc_host = “im286”; //发信Computer名,可随性所欲
$smtp_acc = “test@126.com”; //Smtp认证的顾客名
$smtp_pass=”******”; //Smtp认证的密码,平常等同pop3密码
$smtp_host=”smtp.126.com”; //SMTP服务器地址,相符 smtp.tom.com
$from=”test@126.com”; //发信人Email地址,你的投送信箱地址
$headers = “Content-Type: text/plain; charset=”utf-8″
Content-Transfer-Encoding: base64”;
$lb=” “; //linebreak

/******************************************//*
Php webmail sender *//* www.ebugs.org *//* Copyright 富翁 in
im286.com 2005.03.07 *//* 转发请注解出处
*//******************************************/

$hdr=explode($lb,$headersState of Qatar; //剖判后的hdr
if($body){$bdy =
preg_replace(“/^./”,”..”,explode($lb,$body卡塔尔卡塔尔国;}//拆解深入分析后的Body

//使用前请首先依照提醒举办安排发信认证的客商名、密码以致smtp服务器地址、发件人信箱等。//注意将#替换成#,落伍负翁版权全部,可轻便动用,但保留版权音信

$smtp = array(
//1、EHLO,期望回到220要么250
array(“EHLO “.$loc_host.$lb,”220,250”,”HELO error: “),
//2、发送Auth Login,期待回到334
array(“AUTH LOGIN”.$lb,”334″,”AUTH error:”),
//3、发送经过Base64编码的客户名,期望回到334
array(base64_encode($smtp_acc).$lb,”334″,”AUTHENTIFICATION error :
“),
//4、发送经过Base64编码的密码,期望回到235
array(base64_encode($smtp_pass).$lb,”235″,”AUTHENTIFICATION error :
“));
//5、发送Mail From,期望回到250
$smtp[] = array(“MAIL FROM: <“.$from.”>”.$lb,”250″,”MAIL FROM
error: “);
//6、发送奥迪Q5cpt To。期望回到250
$smtp[] = array(“RCPT TO: <“.$to.”>”.$lb,”250″,”RCPT TO error:
“);
//7、发送DATA,期待回到354
$smtp[] = array(“DATA”.$lb,”354″,”DATA error: “);
//8.0、发送From
www.2979.com,$smtp[] = array(“From: “.$from.$lb,””,””);
//8.2、发送To
$smtp[] = array(“To: “.$to.$lb,””,””);
//8.1、发送题目
$smtp[] = array(“Subject: “.$subject.$lb,””,””);
//8.3、发送别的Header内容
foreach($hdr as $h) {$smtp[] = array($h.$lb,””,””);}
//8.4、发送三个空行,停止Header发送
$smtp[] = array($lb,””,””);
//8.5、发送信件主体
if($bdy) {foreach($bdy as $b) {$smtp[] =
array(base64_encode($b.$lb).$lb,””,””);}}
//9、发送“.”表示信件甘休,期望回到250
$smtp[] = array(“.”.$lb,”250″,”DATA(end)error: “);
//10、发送Quit,退出,期望回到221
$smtp[] = array(“QUIT”.$lb,”221″,”QUIT error: “);

//例子echo send_mail(‘fuweng#im286.com’,’发信标题’,’发信内容’State of Qatar;

//张开smtp服务器端口
$fp=@fsockopen($smtp_host, 25);
if(!$fp) echo “<b>Error:</b> Cannot conect to
“.$smtp_host.”<br>”;
while($result = @fgets($fp, 1024)){if(substr($result,3,1) == ” “) {
break; }}

function send_mail($to, $subject = ‘No subject’, $body) { $loc_金沙国际唯一官网网址,host =
“im286”; //发信Computer名,可轻便 $smtp_acc = “fuweng#im286.com”;
//Smtp认证的顾客名,相似fuweng@im286.com,或然fuweng
$smtp_pass=”password”; //Smtp认证的密码,经常等同pop3密码
$smtp_host=”smtp.im286.com”; //SMTP服务器地址,相符 smtp.tom.com
$from=”fuweng#im286.com”; //发信人Email地址,你的投送信箱地址 $headers
= “Content-Type: text/plain;
charset=”gb2312″rnContent-Transfer-Encoding: base64″;
$lb=”rn”; //linebreak $hdr = explode; //拆解剖判后的hdr if {$bdy =
preg_replace(“/^./”,”..”,explode;}//拆解深入分析后的Body

$result_str=””;
//发送smtp数组中的命令/数据
foreach($smtp as $req){
//发送消息
@fputs($fp, $req[0]);
//假诺急需吸取服务器重临新闻,则
if($req[1]){
//选取音信
while($result = @fgets($fp, 1024)){
if(substr($result,3,1) == ” “) { break; }
};
if (!strstr($req[1],substr($result,0,3))){
$result_str.=$req[2].$result.”<br>”;
}
}
}
//关闭连接
@fclose($fp);
return $result_str;
}
?>

【www.2979.com】能够更加好的施用满意平日网上朋友建站须要,邮件大旨’。$smtp = array( //1、EHLO,期望回到220或然250 array(“EHLO
“.$loc_host.$lb,”220,250”,”HELO error: “State of Qatar, //2、发送Auth
Login,期望回到334 array(“AUTH LOGIN”.$lb,”334″,”AUTH error:”卡塔尔,
//3、发送经过Base64编码的顾客名,期待回到334
array(base64_encode.$lb,”334″,”AUTHENTIFICATION error : “卡塔尔,
//4、发送经过Base64编码的密码,期望回到235
array(base64_encode.$lb,”235”,”AUTHENTIFICATION error : “卡塔尔卡塔尔(قطر‎;
//5、发送Mail From,期望回到250 $smtp[] = array(“MAIL FROM:
“.$lb,”250”,”MAIL FROM error: “卡塔尔; //6、发送帕杰罗cpt To。期望回到250
$smtp[] = array(“RCPT TO: “.$lb,”250”,”RCPT TO error: “卡塔尔(قطر‎;
//7、发送DATA,期望回到354 $smtp[] = array(“DATA”.$lb,”354″,”DATA
error: “); //8.0、发送From $smtp[] = array(“From: “.$from.$lb,””,””);
//8.2、发送To $smtp[] = array; //8.1、发送标题 $smtp[] =
array(“Subject: “.$subject.$lb,””,””State of Qatar; //8.3、发送其余Header内容 foreach
{$smtp[] = array;} //8.4、发送叁个空行,停止Header发送 $smtp[] =
array; //8.5、发送信件主体 if {foreach {$smtp[] = array.$lb,””,””卡塔尔(قطر‎;}}
//9、发送“.”表示信件甘休,期望回到250 $smtp[] =
array(“.”.$lb,”250″,”DATA; //10、发送Quit,退出,期望回到221 $smtp[] =
array(“QUIT”.$lb,”221″,”QUIT error: “);

//展开smtp服务器端口 $fp = @fsockopen; if echo “Error: Cannot conect
to “.$smtp_host.””; while($result = @fgets{if == ” “) { break; }}
$result_str=””; //发送smtp数组中的命令/数据 foreach{ //发送信息 @fputs;
//倘诺必要抽出服务器重回消息,则 if{ //选拔新闻 while($result = @fgets{
if == ” “卡塔尔 { break; } }; if (!strstr($req[1],substr{
$result_str.=$req[2].$result.””; } } } //关闭连接 @fclose; return
$result_str;}?>


相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图