| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 | <?php/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. *//** * Description of mailer * * @author zongheng */class Mailer {    private $emails = null, $eTitle = null, $clientName = null, $content = null;    function configSendParams() {	return json_encode(array('to' => array($this->emails), 'sub' => array('%eTitle%' => array($this->eTitle), '%clientName%' => array($this->clientName), '%content%' => array($this->content))));    }    function send_mail() {	$ch = curl_init();	curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');	curl_setopt($ch, CURLOPT_URL, 'https://sendcloud.sohu.com/webapi/mail.send_template.xml');	curl_setopt($ch, CURLOPT_POSTFIELDS, array('api_user' => 'postmaster@websupport.sendcloud.org',	    'api_key' => 'cDO1GjtY1seH',	    'template_invoke_name' => 'jl_mail',	    'from' => 'postmaster@zhzd.sendcloud.org',	    'fromname' => '纵横计量支付云版',	    'subject' => '纵横计量支付云版:' . $this->eTitle,	    'substitution_vars' => $this->configSendParams()));	$result = curl_exec($ch);//	if ($result === false) { //请求失败//	    echo 'last error : ' . curl_error($ch);//	}	curl_close($ch);	return $result;    }    function setEmails($emails) {	$this->emails = $emails;    }    function seteTitle($eTitle) {	$this->eTitle = $eTitle;    }    function setClientName($clientName) {	$this->clientName = $clientName;    }    function setContent($content) {	$this->content = $content;    }    function send_resetpasswd_mail() {	// 用户重置密码	$resetPasswdConfig = array('to' => array('aboutaboy@yeah.net'), 'sub' => array('%eTitle%' => array('新帐号开通'), '%clientName%' => array('任杰'), '%content%' => array('<p>XXXX公司为你开通了计量支付云版的帐号:</p><p>登录帐号(邮箱):<b><a href="mailto:2448457466@qq.com" target="_blank">2448457466@q<wbr>q.com</a></b></p><p>登录密码:<b>UJN762</b></p><p>请及时登录并修改您的个人信息及密码。</p>')));	return $this->send_mail($emails, $eTitle, $clientName, $content);    }}
 |