NT下基於郵件服務軟體(IMAIL)的郵件發送程式--(網路版)_PHP

來源:互聯網
上載者:User
關鍵字 發送 程式 網路版 郵件 基於 軟體 fp hostrep
IMail

如果你無法在伺服器上安裝IMAIL,那隻能通過socket來發送郵件。但是如果你幸運的話,也可以用163/sina的

smtp服務。

常式如下(原程式由馬毅兄提供):


Mail Form anywhere


if($sendit)
{
$smtpserver="202.110.200.242" ; //將此處設為IMAIL的IP
echo "
" ;
$fp = fsockopen($smtpserver, 25, &$errno, &$errstr, 10) ; //串連smtp伺服器,連接埠25
if(!$fp) die("wrong open smtp SERVER") ;
$hostreplay=fgets($fp,128);
//if (!strstr($hostreplay,"220")) die(" can n't receive the 220 answer ") ;
$smailname=strstr(ltrim($hostreplay),"220 ") ;
$smailname=substr($smailname,0,strpos($smailname,".")) ;
//echo "\nsmailname:$smailname\n" ;
fputs($fp,"$smailname \n") ;
$hostreplay=fgets($fp,128);
//if (!strstr($hostreplay,"250")) die(" can n't receive the 250 answer ") ;

fputs($fp,"MAIL FROM: \n") ;
$hostreplay=fgets($fp,128) ;
if (!strstr($hostreplay,"250")) {
fputs($fp,"MAIL FROM: root\n") ;
$hostreplay=fgets($fp,128) ;
if (!strstr($hostreplay,"250")) {
fputs($fp,"MAIL FROM: root@263.net\n") ;
echo($hostreplay=fgets($fp,128)) ;
if (!strstr($hostreplay,"250")) {
fputs($fp,"MAIL FROM: $from_address\n") ;
$hostreplay=fgets($fp,128) ;
if (!strstr($hostreplay,"250")) die(" can n't receive the 250 answer ") ;
};
};
};
fputs($fp,"RCPT TO: $to_address\n") ;
$hostreplay=fgets($fp,128);
if (!strstr($hostreplay,"250")) {
fputs($fp,"RCPT TO: $mailname\n") ;
$hostreplay=fgets($fp,128) ;
if (!strstr($hostreplay,"250")) echo(" can n't receive the 354 answer") ;
};
fputs($fp,"DATA\n") ;
$hostreplay=fgets($fp,128) ;
if (!strstr($hostreplay,"354")) die(" can n't receive the 250 answer ") ;
$tosend="From: $from_address\n";
$tosend.="To: $to_address\n";
$tosend.="Subject:".str_replace("\N"," ",$subject)."\n你好,這是yukuang發給您的一封測試信!!

\n.\n";
fputs($fp,$tosend) ;
$hostreplay=fgets($fp,128) ;
if (!strstr($hostreplay,"250")) die(" can n't receive the 250 answer ") ;
fputs($fp,"QUIT\n") ;
fclose($fp) ;
echo "發送成功";
exit();
//if($ck_name!='root') die("
bye bye ");

};

?>







該程式在區域網路內調試通過,我的IP是202.110.200.242,供大家測試
  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.