Home > php教程 > php手册 > php 使用qmail发送邮件实现代码

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

WBOY
Release: 2016-05-25 16:49:32
Original
1242 people have browsed it

以前都是利用mail函数或php教程ermail进行邮件发送,今天看这款利用qmail进行邮件发送,写法非常简单,是一款不错的工具.

<?php
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 = "yangxuemei2012@phprm.com"; //发件人
    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.0\n");
    fwrite($handle, "content-type: text/html; charset=\"gb2312\"n\n");
    fwrite($handle, $buffer . "\n");
    pclose($handle); //关闭管道
    return true;
}
$subject = "测试邮件"; 
$uid = $_post[&#39;uid&#39;]; //from信息 
$content= "<html><body>".$u_email 
   ." 您好!<br><br>谢谢,www.phprm.com!<br</body></html>"; //内容信息 
$u_email = "machunjie2003@phprm.com"; //发送到的邮箱 
if (send_check_mail($u_email, $subject, $uid, $content)) { 
    echo "恭喜!发送投票邮件到您的邮箱!<br><br>请检查您的邮箱:<font color=#cc0033>".$u_email." </font><br><br>". $close; 
} else { 
    echo "很不幸,发送投票邮件到您的邮箱失败,请重试或者联系开发人员。<br><br>". $close; 
}
Copy after login

 


文章链接:

随便收藏,请保留本文地址!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template