<?PHP/** @author lazypeople<[email protected]>* @function send mail* @package lazypeople*/functionSend_mail_lazypeople ($to,$subject= ' Your register infomation ',$body) { $loc _host= "SAE"; $smtp _ACC= "Your account address"; $smtp _pass= "Your password"; $smtp _host= "SMTP Address"; $from= "Your e-mail address"; $headers= "Content-type:text/plain; Charset=\ "utf-8\" \r\ncontent-transfer-encoding:base64 "; $lb= "\ r \ n";//LineBreak $HDR=Explode($lb,$headers); if($body) {$bdy=Preg_replace("/^\./","..",Explode($lb,$body));}//?????? Body $SMTP=Array( Array("EHLO".$loc _host.$lb, "220,250", "HELO Error:"),Array("AUTH LOGIN".)$lb, "334", "AUTH Error:"),Array(Base64_encode($smtp _ACC).$lb, "334", "Authentification Error:"),Array(Base64_encode($smtp _pass).$lb, "235", "Authentification Error:")); $SMTP[] =Array("MAIL From: <".)$from." > ".$lb, "$", "MAIL from Error:"); $SMTP[] =Array("RCPT to: <".$to." > ".$lb, "$", "RCPT to Error:"); $SMTP[] =Array("DATA".)$lb, "354", "DATA Error:"); $SMTP[] =Array("From:".)$from.$lb,"",""); $SMTP[] =Array("To:".)$to.$lb,"",""); $SMTP[] =Array("Subject:".)$subject.$lb,"",""); foreach($HDR as $h) {$SMTP[] =Array($h.$lb,"","");} $SMTP[] =Array($lb,"",""); if($bdy) {foreach($bdy as $b) {$SMTP[] =Array(Base64_encode($b.$lb).$lb,"","");}} $SMTP[] =Array(".".$lb, "$", "DATA (end) Error:"); $SMTP[] =Array("QUIT".)$lb, "221", "QUIT Error:"); $fp= @Fsockopen($smtp _host, 25); if(!$fp)Echo"Error:cannot conect to".$smtp _host.""; while($result= @fgets($fp, 1024)) {if(substr($result, 3, 1) = = "") { Break; }} $result _str=""; 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.""; } } } @fclose($fp); return $result _str;} Send_mail_lazypeople (' [email protected] ', ' hello ', ' hello ');//Test?>
From Http://lazy.changes.com.cn/html/352.html#toc-e69cace69599e7a88be6ba90e7a081e68993e58c85e4b88be8bdbde59cb0e59d80
Sina App Engine (SAE) Introductory Tutorial (9)-saemail (mail) use