修改 Sendmail 插件邮件样式

简爱EMLOG2013-2-20 11:4987948

修改 Sendmail 插件发送通知邮件内容

具体代码 如下(原内容 就不再贴了):


<?php
/*
Plugin Name: Sendmail
Version: 3.7
Plugin URL: http://kller.cn/?post=61
Description: 发送博客留言至E-mail。
Author: KLLER
Author Email: kller@foxmail.com
Author URL: http://kller.cn
*/

!defined('EMLOG_ROOT') && exit('access deined!');
require_once(EMLOG_ROOT.'/content/plugins/kl_sendmail/class/class.phpmailer.php');
function kl_sendmail_do($mailserver, $port, $mailuser, $mailpass, $mailto, $subject,  $content, $fromname){
	$mail = new PHPMailer();
	$mail->CharSet = "UTF-8";

	if(KL_MAIL_SENDTYPE == 1)
	{
		$mail->IsSMTP();
	}else{
		$mail->IsMail();
	}
	$mail->Host = $mailserver;
	$mail->SMTPAuth = true;
	$mail->Username = $mailuser;
	$mail->Password = $mailpass;

	$mail->From = $mailuser;
	$mail->FromName = $fromname;

	$mail->AddAddress($mailto);
	$mail->Subject = $subject;
	$mail->Body = $content;
	$mail->AltBody = "text/html";
	if($mail->Host == 'smtp.gmail.com') $mail->SMTPSecure = "ssl";
	if(!$mail->Send())
	{
		echo $mail->ErrorInfo;
		return false;
	}else{
		return true;
	}
}
function kl_sendmail_get_comment_mail()
{
	include(EMLOG_ROOT.'/content/plugins/kl_sendmail/kl_sendmail_config.php');
	if(KL_IS_SEND_MAIL == 'Y' || KL_IS_REPLY_MAIL == 'Y')
	{
		$comname = isset($_POST['comname']) ? addslashes(trim($_POST['comname'])) : '';
		$comment = isset($_POST['comment']) ? addslashes(trim($_POST['comment'])) : '';
		$commail = isset($_POST['commail']) ? addslashes(trim($_POST['commail'])) : '';
		$comurl = isset($_POST['comurl']) ? addslashes(trim($_POST['comurl'])) : '';
		$gid = isset($_POST['gid']) ? intval($_POST['gid']) : -1;
		$pid = isset($_POST['pid']) ? intval($_POST['pid']) : 0;

		$blogname = Option::get('blogname');
		$Log_Model = new Log_Model();
		$logData = $Log_Model->getOneLogForHome($gid);
		$log_title = $logData['log_title'];
		$subject = "日志《{$log_title}》收到了新的评论";
		if(strpos(KL_MAIL_TOEMAIL, '@139.com') === false)
		{
			$content = "评论内容:{$comment}<br /><br />发件人:".$comname."<br />";
			if(!empty($commail)) $content .= "Email:{$commail}<br />";
			if(!empty($comurl)) $content .= "主页:{$comurl}<br />";
			$content .= "<br /><strong>=> 现在就前往<a href=\"{$_SERVER['HTTP_REFERER']}\" target=\"_blank\">日志页面</a>进行查看</strong><br />";
		}else{
			$content = $comment;
		}
		if(KL_IS_SEND_MAIL == 'Y')
		{
			if(ROLE == 'visitor') kl_sendmail_do(KL_MAIL_SMTP, KL_MAIL_PORT, KL_MAIL_SENDEMAIL, KL_MAIL_PASSWORD, KL_MAIL_TOEMAIL, $subject, $content, $blogname);
		}
		if(KL_IS_REPLY_MAIL == 'Y')
		{
			if($pid > 0)
			{
				$DB = mysql::getInstance();
				$Comment_Model = new Comment_Model();
				$pinfo = $Comment_Model->getOneComment($pid);
				if(!empty($pinfo['mail']))
				{
					$subject = "您在【简爱 GouJi.org】发表的评论收到了回复";
					$content = '
<div align="center" style="font: 13px/1.5 microsoft yahei,Verdana,Arial,Helvetica,sans-serif;">
  <br/><br/>
  <div align="left" style="text-decoration:none;width:580px;font-size:14px;padding:10px 15px;margin-bottom:20px;border:1px solid #ccc;border-radius:4px;">
    <div style="line-height:40px;padding-bottom:5px;hight:40px;font-weight:normal;border-bottom:1px dashed #ccc;"><strong><span style="font-size:28px;color:#08d;">简爱 &nbsp; GouJi.org&nbsp;&nbsp;&nbsp;&nbsp;</span>您在 《简爱 GouJi.org》 的评论 有人回复。</strong></div>
    <p><strong>'.$pinfo['poster'].'</strong> , 您好:</p>
    <p><strong>&nbsp;&nbsp;&nbsp;&nbsp;您之前在 《'.$log_title.'》 发表的的评论:</strong></p>
    <p>&nbsp;&nbsp;&nbsp;&nbsp;'.$pinfo['comment'].'</p>
    <br/>
    <p><strong>'.$comname.' </strong> 给您的回复:</p>
    <p>&nbsp;&nbsp;&nbsp;&nbsp;'.$comment.'</p>
    <br/>
    <p><strong>您可以点击 <a href="'.Url::log($gid)."#".$pid.'" style="text-decoration: none;outline:none;" target="_blank">查看该日志</a></strong></p>
    <p><strong>感谢您对 <a href="'.BLOG_URL.'" style="text-decoration: none;outline:none;" target="_blank">'.$blogname.'</a> 的关注, 欢迎 <a href="'.BLOG_URL.'rss.php" style="text-decoration: none;outline:none;" target="_blank">订阅本站</a> </strong></p>
    <br/>
    <p style="color:#999; margin:26px 0 0 0; font-size:12px;">
      简爱的博客:<a href="http://gouji.org" target="_blank" style="color:#999;">http://gouji.org</a><br>
      <span style="text-align:right;background:#ccc;height:1px;widli:100%;overflow:hidden;display:block;margin:8px 0;"></span>
      简爱<br>
      '.gmdate("Y年 m月 d日",time()+8*3600).'
    </p>
  </div>
  <p>Powered by <a href="http://gouji.org/" style="text-decoration: none;outline:none;" target="_blank" title="简爱">GouJi.org</a></p>
  <br/>
</div>';
					kl_sendmail_do(KL_MAIL_SMTP, KL_MAIL_PORT, KL_MAIL_SENDEMAIL, KL_MAIL_PASSWORD, $pinfo['mail'], $subject, $content, $blogname);
				}
			}
		}
	}else{
		return;
	}
}
addAction('comment_saved', 'kl_sendmail_get_comment_mail');

function kl_sendmail_get_twitter_mail($r, $name, $date, $tid)
{
	include(EMLOG_ROOT.'/content/plugins/kl_sendmail/kl_sendmail_config.php');
	if(KL_IS_TWITTER_MAIL == 'Y')
	{
		$DB = Mysql::getInstance();
		$blogname = Option::get('blogname');
		$sql = "select a.content, b.username from ".DB_PREFIX."twitter a left join ".DB_PREFIX."user b on b.uid=a.author where a.id={$tid}";
		$res = $DB->query($sql);
		$row = $DB->fetch_array($res);
		$author = $row['username'];
		$twitter = $row['content'];
		$subject = "{$author}发布的碎语收到了新的回复";
		if(strpos(KL_MAIL_TOEMAIL, '@139.com') === false)
		{
			$content = "{$author}发布的碎语:{$twitter}<br /><br />{$name}对碎语的回复:{$r}<br /><br /><strong>=> 现在就前往<a href=\"{$_SERVER['HTTP_REFERER']}\" target=\"_blank\">碎语页面</a>进行查看</strong><br />";
		}else{
			$content = $r;
		}
		if(ROLE == 'visitor') kl_sendmail_do(KL_MAIL_SMTP, KL_MAIL_PORT, KL_MAIL_SENDEMAIL, KL_MAIL_PASSWORD, KL_MAIL_TOEMAIL, $subject, $content, $blogname);
	}
}
addAction('reply_twitter', 'kl_sendmail_get_twitter_mail');

function kl_sendmail_put_reply_mail($commentId, $reply)
{
	global $userData;
	include(EMLOG_ROOT.'/content/plugins/kl_sendmail/kl_sendmail_config.php');
	if(KL_IS_REPLY_MAIL == 'Y')
	{
		$DB = mysql::getInstance();
		$blogname = Option::get('blogname');
		$Comment_Model = new Comment_Model();
		$commentArray = $Comment_Model->getOneComment($commentId);
		extract($commentArray);
		$subject="您在【{$blogname}】发表的评论收到了回复";
		if(strpos($mail, '@139.com') === false)
		{
			$emBlog = new Log_Model();
			$logData = $emBlog->getOneLogForHome($gid);
			$log_title = $logData['log_title'];
			$content =  '
<div align="center" style="font: 13px/1.5 microsoft yahei,Verdana,Arial,Helvetica,sans-serif;">
  <br/><br/>
  <div align="left" style="text-decoration:none;width:580px;font-size:14px;padding:10px 15px;margin-bottom:20px;border:1px solid #ccc;border-radius:4px;">
    <div style="line-height:40px;padding-bottom:5px;hight:40px;font-weight:normal;border-bottom:1px dashed #ccc;"><strong><span style="font-size:28px;color:#08d;">简爱 &nbsp; GouJi.org&nbsp;&nbsp;&nbsp;&nbsp;</span>您在 《简爱 GouJi.org》 的评论 有人回复。</strong></div>
    <p><strong>'.$pinfo['poster'].'</strong> , 您好:</p>
    <p><strong>&nbsp;&nbsp;&nbsp;&nbsp;您之前在 《'.$log_title.'》 发表的的评论:</strong></p>
    <p>&nbsp;&nbsp;&nbsp;&nbsp;'.$pinfo['comment'].'</p>
    <br/>
    <p><strong>'.$comname.' </strong> 给您的回复:</p>
    <p>&nbsp;&nbsp;&nbsp;&nbsp;'.$comment.'</p>
    <br/>
    <p><strong>您可以点击 <a href="'.Url::log($gid)."#".$pid.'" style="text-decoration: none;outline:none;" target="_blank">查看该日志</a></strong></p>
    <p><strong>感谢您对 <a href="'.BLOG_URL.'" style="text-decoration: none;outline:none;" target="_blank">'.$blogname.'</a> 的关注, 欢迎 <a href="'.BLOG_URL.'rss.php" style="text-decoration: none;outline:none;" target="_blank">订阅本站</a> </strong></p>
    <br/>
    <p style="color:#999; margin:26px 0 0 0; font-size:12px;">
      简爱的博客:<a href="http://gouji.org" target="_blank" style="color:#999;">http://gouji.org</a><br>
      <span style="text-align:right;background:#ccc;height:1px;widli:100%;overflow:hidden;display:block;margin:8px 0;"></span>
      简爱<br>
      '.gmdate("Y年 m月 d日",time()+8*3600).'
    </p>
  </div>
  <p>Powered by <a href="http://gouji.org/" style="text-decoration: none;outline:none;" target="_blank" title="简爱">GouJi.org</a></p>
  <br/>
</div>';
		}else{
			$content = $reply;
		}
		if($mail != '')	kl_sendmail_do(KL_MAIL_SMTP, KL_MAIL_PORT, KL_MAIL_SENDEMAIL, KL_MAIL_PASSWORD, $mail, $subject, $content, $blogname);
	}else{
		return;
	}
}
addAction('comment_reply', 'kl_sendmail_put_reply_mail');

function kl_sendmail_menu()
{
	echo '<div class="sidebarsubmenu" id="kl_sendmail"><a href="./plugin.php?plugin=kl_sendmail">邮件设置</a></div>';
}
addAction('adm_sidebar_ext', 'kl_sendmail_menu');
?>


本文出自简爱博客,转载时请注明出处及相应链接。

评论

  1. Sang2014-12-08 00:04回复

    路过看看= =居然是EMLOG

    1. 简爱2014-12-08 12:33回复

      @Sang:这东西比着写个框就好了[亲亲/]
      跟程序没太大的关联

  2. 李明2014-11-18 09:04回复

    使用了,谢谢分享!

  3. 追梦的风筝2013-07-20 18:20回复

    代码盲,复制了,放进去报错

    1. 简爱2013-07-20 20:06回复

      @追梦的风筝:是不插件升级了  我没升过

  4. 追梦的风筝2013-07-20 17:48回复

    这个区看看,试试修改哈

  5. 黎健雄2013-02-23 15:04回复

    好吧,其实我是为了这个而来的。收藏先,下次再来折腾。

    1. 简爱2013-02-23 15:56回复

      @黎健雄:嘿嘿  按需折腾