喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 帮助

RSS 订阅当前论坛  

喜悦证交所已经关闭

上一主题 下一主题
     
标题: [代码] 发个yeah.net的邮件发送类  
 
millken
高级会员
Rank: 4


UID 73040
精华 0
积分 743
帖子 522
金钱 743 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2006-5-9
来自 REFERER
状态 在线
[广告]: q m
发个yeah.net的邮件发送类



<?
//====================================================
//        FileName:    mailyeah.php
//        Summary:    yeah.net邮件系统
//        Author:        millken(迷路林肯)
//        LastModifed:2008-3-4
//        copyright (c)2008 [email]millken@gmail.com[/email]
//====================================================
class mailyeah {
    private 
$config = array();  //邮箱配置
    
public $isHTML true;  //是否HTML邮件
    
public $saveSentCopy false//是否在邮箱中保存副本

    
public function __construct($user,$pass) {
        
$this->config['user'] = $user;
        
$this->config['pass'] = $pass;
        
self::connect();
    }

    private function 
connect() {
        
$fp fsockopen("entry.yeah.net"80$errno$errstr30);
        if (!
$fp) {
            return 
false;
        }
        else {
            
$post "bCookie=&user=".$this->config['user']."&pass=".$this->config['pass']."&style=4&RmbUser=on";
            
$out  "POST /cgi/login?hid=10010102&verifycookie=1&language=0 HTTP/1.1rn";
            
$out .= "Referer: [url]http://www.yeah.net/[/url]rn";
            
$out .= "Host: entry.yeah.netrn";
            
$out .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.8.1.7) Gecko/20070914 (FoxPlus) Firefox/2.0.0.7rn";
            
$out .= "Connection: Keep-Alivern";
            
$out .= "Content-Type: application/x-www-form-urlencodedrn";
            
$out .= "Content-length: ".strlen($post)."rn";
            
$out .= "Cookie: logType=xy3; zUser=".$this->config['user']."rn";
            
$out .= "rn$postrn";
            
fwrite($fp$out);
            while (!
feof($fp)) {
                
$output .= fgets($fp128);
           }
            
fclose($fp);
        }
        
preg_match("|Set-Cookie: Coremail=(.*); path=/;|i",$output,$cookies);
        
preg_match("|Location: (.*)s+|i",$output,$location); //邮件主机
        
$locations parse_url($location[1]);
        
$this->config['host'] = $locations['host'];
        
$this->config['sid'] = substr($locations['query'],4,32);
        
$this->config['Coremail'] = $cookies[1];
        unset(
$cookies,$locations,$output);
        
/*
        //file_put_contents($this->cookiefile,"<?PHPn$this->config = ".var_export($this->config,true)."n?>",LOCK_EX);
        */
    
}

    private function 
is_email($email) {
        return 
strlen($email) > && preg_match('/A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+(?:[a-z]{2}|com|org|net|gov|biz|info|name|aero|biz|info|jobs|museum)b)Z/i', $email);
    }

    public function send($to='', $subject='', $content='', $from = '') {
        if(strstr($to,'
,')){
            foreach((explode('
,',$to)) as $key) {
                if($this->is_email($key)) {
                    $toA[] = '
<string>'.$key.'</string>';
                }
            }
            $to = implode('',$toA);
        }
        else {
            $to = '
<string>'.$to.'</string>';
        }
        $content = $this->isHTML?htmlspecialchars($content,ENT_NOQUOTES):$content;
        $from = $from?$from:$this->config['
user'];
        $isHTML = $this->isHTML?'
true':'false';
        $saveSentCopy = $this->saveSentCopy?'
true':'false';
        $mail_body = '
<?xml version="1.0"?><object><string name="action">deliver</string><object name="attrs"><string name="config">"'.$from.'" &lt;'.$this->config['user'].'@yeah.net&gt;</string><array name="to">'.$to.'</array><array name="cc"/><array name="bcc"/><string name="subject">'.$subject.'</string><string name="content">'.$content.'</string><boolean name="isHtml">'.$isHTML.'</boolean><int name="priority">3</int><boolean name="saveSentCopy">'.$saveSentCopy.'</boolean><boolean name="requestReadReceipt">false</boolean><string name="charset">gbk</string></object></object>';

        $fp = fsockopen($this->config['host'], 80, $errno, $errstr, 30);
        if (!$fp) {
            return false;
        }
        else {
            $out  = "POST /a/s?sid=".$this->config['sid']."&func=mbox:compose HTTP/1.1rn";
            $out .= "Host: ".$this->config['host']."rn";
            $out .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.8.1.7) Gecko/20070914 (FoxPlus) Firefox/2.0.0.7rn";
            $out .= "Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7rn";
            $out .= "Keep-Alive: 300rn";
            $out .= "Connection: Closern";
            $out .= "Content-Type: application/xmlrn";
            $out .= "Referer: http://".$this->config['host']."/a/f/dm3/0801181756/index_v7.htmrn";
            $out .= "Content-length: " . (strlen($mail_body)) . "rn";
            $out .= "Cookie: "."logType=xy3; zUser=".$this->config['user']."; Coremail=".$this->config['Coremail']."; mail_style=dm3rn";
            $out .= "Pragma: no-cachern";
            $out .= "Cache-Control: no-cachern";
            $out .= "rn$mail_bodyrn";
            fwrite($fp, $out);
            while (!feof($fp)) {
                $output = fgets($fp, 255);
                $view_output .= $output;
                if($output=="n" || $output == "rn" || $output == "nl") {
                       $header = $view_output;
                       $view_output = '';
                }
           }
            fclose($fp);
            if(strpos($view_output,'S_OK') !== FALSE) {
                return true;
            }
            else{
                return false;
            }
        }
    }
}
set_time_limit(0);
$mail = new mailyeah('autoreply','autoreply');
$mail->send('[email]your@email.com[/email]','title','content','yourname');
?>
附件下载后需把.zip去掉.

[ 本帖最后由 millken 于 2008-3-7 11:41 AM 编辑 ]


 附件: 您所在的用户组无法下载或查看附件



Blogger 免费搭建的个人BLOG
2008-3-7 11:40 AM#1
查看资料  Blog  发短消息  顶部
 
wildlily980
中级会员
Rank: 3Rank: 3
中级会员



UID 38831
精华 0
积分 376
帖子 395
金钱 376 喜悦币
威望 0
人脉 0
阅读权限 30
注册 2004-10-24
状态 离线
[推荐阅读] 大少爷,好几个月没来看您了,您好吗?
可惜yeah.net现在不支持新注册用户smtp了。



寻找工作中。
2008-3-7 02:12 PM#2
查看资料  发短消息  顶部
 
songlv (超级版主)
论坛元老
Rank: 8Rank: 8


UID 73828
精华 0
积分 3021
帖子 693
金钱 3017 喜悦币
威望 0
人脉 4
阅读权限 90
注册 2006-5-22
状态 在线
[推荐阅读] Hello Word!之VC编写PHP5扩展
晕倒 网易的邮件都不允许 新用户 发 smtp



不要跑  不要玩   不要看  不要  
2008-3-7 02:36 PM#3
查看资料  访问主页  Blog  发短消息  顶部
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 




Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 0.032230 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP