欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

php 发送邮件与pop3邮件登录代码

程序员文章站 2022-03-14 22:09:11
...
php发送邮件与pop3邮件登录代码
rn"; //设置email头
    ini_set('sendmail_from', $send_addr);
    mail($to, $subject, $body, $header);
}
?>

pop3邮箱登录

smtp登录验证函数

function smtp_login($host, $username, $password) {
    global $debug;
    if (emptyempty($host)) {
        return false;
    }
    if ($debug) echo "open hostname: " . $host . ",port: " . $port . "n";
    $conn = @fsockopen($host, 25, $err_no, $err_str, 5);
    if (!$conn) {
        return false;
    }
    $ret_info = fgets($conn, 1024);
    if (substr($ret_info, 0, 3) == "220") {
        fputs($conn, "helo localhostrn");
        if (substr(fgets($conn, 1024) , 0, 3) == "250") {
            if (login($conn, $username, $password, 25)) {
                return true;
            }
        }
    }
    return false;
}

imap登录验证函数

function imap_login($host, $username, $password) {
    global $debug;
    if (emptyempty($host)) {
        return false;
    }
    if ($debug) echo "open hostname: " . $host . ",port: " . $port . "n";
    $conn = @fsockopen($host, 143, $err_no, $err_str, 5);
    if (!$conn) {
        return false;
    }
    $ret_info = fgets($conn, 1024);
    if (strpos($ret_info, "ok")) {
        fputs($conn, "a001 login $username $passwordrn");
        $ret = fgets($conn, 1024);
        if (strpos($ret, "login ok")) {
            return true;
        }
    }
    return false;
}


教程网址:

欢迎收藏∩_∩但请保留本文链接。