文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>phpmailer 群发代码

phpmailer 群发代码

时间:2008-08-12  来源:yueming


?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 = "[email protected]";
        $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" ;
        }
    }
}
?>


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载