//调用发送邮件 Monxin专用(PHP代码函数)
//本代码基于Monxin 运行
//代码来源:Monxin ./config/functions.php
function send_email($config,$pdo,$id=0){
$id=intval($id);
if($id==0){
$sql="select * from ".$pdo->index_pre."email_msg where `state`='1' order by `time` asc limit 0,1";
}else{
$sql="select * from ".$pdo->index_pre."email_msg where `id`='$id'";
}
$r=$pdo->query($sql,2)->fetch(2);
if($r['addressee']!='' && $r['content']!=''){
$r=de_safe_str($r);
require_once("./plugin/mail/class.phpmailer.php");
$result=sendmail($config['web']['name'],$r['addressee'],$r['title'],$r['content'],get_mail_info($pdo,$r['addressee']));
ob_clean();
ob_end_flush();
if($result){
$sql="update ".$pdo->index_pre."email_msg set `state`='2' where `id`='".$r['id']."'";
$pdo->exec($sql);
return true;
}else{
$sql="update ".$pdo->index_pre."email_msg set `state`='3' where `id`='".$r['id']."'";
$pdo->exec($sql);
return false;
}
}else{return false;}
}