php 使用qmail发送邮件实现代码

作者:袖梨 2022-06-24

function send_check_mail($email, $subject,$uid,$buffer)
{
    echo "hello";
 $command = "/var/qmail/bin/qmail-inject ".$email; //qmail程序地址,$email是要发送的地址
 $handle = popen($command, "w"); //打开管道
 if (!$handle) {
  return false;
 }

 $from = "[email protected]"; //发件人
 fwrite($handle, "from: ".$from."n"); //往管道写数据
 fwrite($handle, "return-path: ".$from."n");
 fwrite($handle, "to: ".$uid."n");
 fwrite($handle, "subject: ".$subject."n");
 fwrite($handle, "mime-version: 1.0n");
 fwrite($handle, "content-type: text/html; charset="gb2312"nn");
 fwrite($handle, $buffer."n");
 pclose($handle); //关闭管道

 return true;
}
$subject = "测试邮件";

$uid = $_post['uid']; //from信息
$content= "".$u_email

   ." 您好!

谢谢,www.111com.net"; //内容信息

$u_email = "[email protected]"; //发送到的邮箱
if (send_check_mail($u_email, $subject, $uid, $content)) {

 echo "恭喜!发送投票邮件到您的邮箱!

请检查您的邮箱:".$u_email."

". $close;
 } else {

 echo "很不幸,发送投票邮件到您的邮箱失败,请重试或者联系开发人员。

". $close;

}

相关文章

精彩推荐