Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5009330
  • 博文数量: 921
  • 博客积分: 16037
  • 博客等级: 上将
  • 技术积分: 8469
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-05 02:08
文章分类

全部博文(921)

文章存档

2020年(1)

2019年(3)

2018年(3)

2017年(6)

2016年(47)

2015年(72)

2014年(25)

2013年(72)

2012年(125)

2011年(182)

2010年(42)

2009年(14)

2008年(85)

2007年(89)

2006年(155)

分类:

2008-08-12 13:02:45

<?php
/**
* mailer
* 用来发送email,what the client what is so complex!
*
* related table:lr_mailsubscriber
*/

class mailer extends Controller {

    function mailer(){
        parent::Controller();
        //$this->load->scaffolding("lr_users") ;

        
    }
    
    function index(){
        //$this->load->view('welcome_message');

        header("Location:/index.php");
    }
    
    public function doGroupSending($subject , $content){
        if (empty($subject) || empty($content)){
            echo "群发email的主题或者内容为空";
            exit(0) ;
        }
        require_once("./WEB-INF/3partylibs/phpmailer/class.phpmailer.php") ;
        $mail = new PHPMailer();
        $mail->From = "golifecn@golife.cn";
        $success = true ;
        /*loop address*/
        $model = &AdminModelFactory::Factory("MailsubscriberModel") ;
        $subscribers = $model->getAll() ;
        foreach ($subscribers as $v){
            $mail->ClearAddresses() ;
            $mail->AddAddress($v['email']);
            $mail->Subject = $subject;
            $mail->Body = $content;
            $mail->IsHTML(true);
            if (!$mail->Send()){
                $success = false ;
                $error .= $v['email'] ;
            }
        }
        /*~end loop address*/
        if ($success){
            echo "群发email给所有用户成功" ;
        } else {
            echo "群发失败
"
;
            echo "一下用户没有成功发送:$error" ;
        }
    }
}
?>

阅读(2639) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~