实现邀请专家注册及邀请专家评审的email发送

This commit is contained in:
wlx 2011-10-13 12:58:57 +00:00
parent 662713f0ea
commit 59400804be
1 changed files with 10 additions and 39 deletions

View File

@ -290,7 +290,7 @@ class Admin_ReviewController extends Zend_Controller_Action
$sql = "insert into mdexpertreview (id,uuid) values ('$v','$uuid')"; $sql = "insert into mdexpertreview (id,uuid) values ('$v','$uuid')";
$expinfo="select realname from users where id='$v'"; $expinfo="select realname,email from users where id='$v'";
$rs = $this->db->query($expinfo); $rs = $this->db->query($expinfo);
$expinfo = $rs->fetch(); $expinfo = $rs->fetch();
@ -302,31 +302,13 @@ class Admin_ReviewController extends Zend_Controller_Action
$update = "update mdstatus set status=2 where uuid='$uuid'"; $update = "update mdstatus set status=2 where uuid='$uuid'";
@$this->db->exec($update); @$this->db->exec($update);
} }
//实例化EmailText
$mailtp=new EmailText(); //实例化EmailText $mailtp=new EmailText($this->db,'invite-expert-review',array('user'=>$expinfo['realname'],'uuid'=>$uuid,'title'=>$md['title']));
$mailtp->db = $this->db; //传入PDO类型数据库对象
$mailtp->tmpid = "expinvite"; //传入模板ID或标示符传入ID是使用int类型
$mailtp->data = array( //传入要替换的数据
'user' => $expinfo['realname'], //用户名 {user}
'uuid' => $uuid, //uuid {uuid}
'title' => $md['title'] //元数据标题 {title}
);
$body = $mailtp->loadtmp(); //加载模板
$subject = $mailtp->tmpinfo['subject']; //标题(顺序不能变,必须先加载模板后调用标题,减少数据库查询的次数)
if($body === false)
{
$this->messenger->addMessage('模板加载失败');
$this->_redirect("/admin/review/invite/?id=$id");
}
$email = "la5c@qq.com";
$mail=new WestdcMailer($this->view->config->smtp); $mail=new WestdcMailer($this->view->config->smtp);
$mail->setBodyText($body); $mail->setBodyText($mailtp->getBody());
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组'); $mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$mail->addTo($email); $mail->addTo($expinfo['email']);
$mail->setSubject($subject); $mail->setSubject($mailtp->getSubject());
if($mail->send()) if($mail->send())
{ {
$this->messenger->addMessage('成功邀请专家:'.$expinfo['realname']); $this->messenger->addMessage('成功邀请专家:'.$expinfo['realname']);
@ -656,23 +638,12 @@ class Admin_ReviewController extends Zend_Controller_Action
if($this->db->insert('users',$data)) if($this->db->insert('users',$data))
{ {
$mail=new WestdcMailer($this->view->config->smtp); $mail=new WestdcMailer($this->view->config->smtp);
$body="尊敬的西部数据中心用户: $mailtp=new EmailText($this->db,'expert-register',array('user'=>$username,'password'=>$password));
您已经成功注册,请妥善保管您的账号信息 $mail->setBodyText($mailtp->getBody());
用户名:$username
密码: $password
感谢您的注册
西部数据中心服务组";
$body.="";
$mail->setBodyText($body);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组'); $mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$mail->addTo($email); $mail->addTo($email);
$mail->setSubject('欢迎注册成为西部数据中心用户'); $mail->setSubject($mailtp->getSubject());
$mail->send(); $mail->send();
$sql="select id from users where username='{$data['username']}'"; $sql="select id from users where username='{$data['username']}'";