/*
|----------------------------------------------------------------------------
| 发送邮件
例:
$conf = array(
'to'=>'1019822077@qq.com',
'from'=>'woai_php@sina.com',
'subject'=>'邮件标题',
'content'=>'邮件内容',
'user'=>'woai_php',
'pwd'=>'这里是密码',
'smtp'=>'smtp.sina.com',
);
sendMail($conf);
|----------------------------------------------------------------------------
|
*/
function sendMail($conf){
$fp = @fsockopen($conf[smtp],25, $errno, $errstr,30);
fputs($fp, "HELO hi"."rn");//和服务器打招呼,可省略
fputs($fp, "AUTH LOGIN ".base64_encode($conf[user])."rn");
fputs($fp, base64_encode($conf[pwd])."rn");
fputs($fp,"MAIL FROM:"."<".$conf[from].">"."rn");
fputs($fp,"RCPT TO:"."<".$conf[to].">"."rn");
fputs($fp,"DATA "."rn");
fgets($fp, 512);
$header .= "MIME-Version:1.0rn";
$header .= "Content-Type:text/htmlrn";
$header .= "To: ".$conf[to]."rn";
$header .= "From: ".$conf[from]."<".$conf[from].">rn";
$header .= "Subject: ".$conf[subject]."rn";
$header .= "Date: ".date("r")."rn";
fputs($fp, $header."rn".$conf[content]."rn.rn");
fputs($fp,"QUIT "."rn");
fgets($fp, 512);
fclose($fp);
}

用fsockopen发邮件
标签: