php

用fsockopen发邮件

dafenqi
2023-08-07 / 0 评论 / 23 阅读 / 正在检测是否收录...

用fsockopen发邮件

/*
|----------------------------------------------------------------------------
| 发送邮件
例:
$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 = "";
  $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);
}
0

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /www/wwwroot/testblog.58heshihu.com/var/Widget/Archive.php on line 1032

评论 (0)

取消