最模板 - 外贸网站建设,外贸网站模板

最模板

当前位置: 首页 > 建站教程 > php教程 >

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

时间:2014-06-09 16:40来源: 作者: 点击: 次
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 , $subje

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

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

pop3邮箱登录

  1. function pop3_login($host,$username,$password) 
  2. { 
  3.         global $debug; 
  4.     if(emptyempty($host)) { 
  5.         return false; 
  6.     } 
  7.     if($debug) 
  8.         echo "open hostname: ".$host.",port: ".$port."n"; 
  9.     $conn = @fsockopen($host,110,$err_no,$err_str,5); 
  10.     if(!$conn) { 
  11.         return false; 
  12.     } 
  13.     $ret_info = fgets($conn,1024); 
  14.     if(substr($ret_info,0,3) == "+ok") { 
  15.                 if(login($conn,$username,$password)) { 
  16.                         return true; 
  17.                 } 
  18.     } 
  19.     return false; 
  20. } 

smtp登录验证函数

  1. function smtp_login($host,$username,$password) 
  2. { 
  3.         global $debug; 
  4.     if(emptyempty($host)) { 
  5.         return false; 
  6.     } 
  7.     if($debug) 
  8.         echo "open hostname: ".$host.",port: ".$port."n"; 
  9.     $conn = @fsockopen($host,25,$err_no,$err_str,5); 
  10.     if(!$conn) { 
  11.         return false; 
  12.     } 
  13.     $ret_info = fgets($conn,1024); 
  14.     if(substr($ret_info,0,3) == "220") { 
  15.           fputs($conn,"helo localhostrn"); 
  16.           if(substr(fgets($conn,1024),0,3) == "250") { 
  17.                 if(login($conn,$username,$password,25)) { 
  18.                         return true; 
  19.                 } 
  20.           } 
  21.     } 
  22.     return false; 
  23. } 

imap登录验证函数

  1. function imap_login($host,$username,$password) 
  2. { 
  3.         global $debug; 
  4.     if(emptyempty($host)) { 
  5.         return false; 
  6.     } 
  7.     if($debug) 
  8.         echo "open hostname: ".$host.",port: ".$port."n"; 
  9.     $conn = @fsockopen($host,143,$err_no,$err_str,5); 
  10.     if(!$conn) { 
  11.         return false; 
  12.     } 
  13.     $ret_info = fgets($conn,1024); 
  14.         if(strpos($ret_info,"ok")) { 
  15.                 fputs($conn,"a001 login $username $passwordrn"); 
  16.                 $ret = fgets($conn,1024); 
  17.                 if(strpos($ret,"login ok")) { 
  18.                         return true; 
  19.                 } 
  20.         } 
  21.         return false; 
  22. } 
(责任编辑:admin)
------分隔线----------------------------
栏目列表
推荐内容