加入收藏 | 设为首页 | 会员中心 | 我要投稿 汽车网 (https://www.0577qiche.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2023-06-01 13:15:40 所属栏目:PHP教程 来源:
导读:php发送邮件与pop3邮件登录代码

function send_msg($to,$subject,$body) {
$send_addr = 'admin@test.com'; //发送人地址
$header = "from: admin <".$send_addr.">rn"; //设置email头
ini_set(&
php发送邮件与pop3邮件登录代码

function send_msg($to,$subject,$body) { 
$send_addr = 'admin@test.com';   //发送人地址 
$header = "from: admin <".$send_addr.">rn"; //设置email头 
ini_set('sendmail_from',$send_addr); 
mail($to,$subject,$body,$header); 

pop3邮箱登录

function pop3_login($host,$username,$password) 

        global $debug; 
    if(emptyempty($host)) { 
        return false; 
    } 
    if($debug) 
        echo "open hostname: ".$host.",port: ".$port."n"; 
    $conn = @fsockopen($host,110,$err_no,$err_str,5); 
    if(!$conn) { 
        return false; 
    } 
    $ret_info = fgets($conn,1024); 
    if(substr($ret_info,0,3) == "+ok") { 
                if(login($conn,$username,$password)) { 
                        return true; 
                } 
    } 
    return false; 

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; 

(编辑:汽车网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章