uchome中的发送邮件
来源:互联网 发布:淘宝商品如何靠前 编辑:程序博客网 时间:2024/05/22 14:05
1:将要发送的邮件加入到队列mailcron,mailqueue
//检查是否存在当前队列
$cid = 0;
$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('mailcron')." WHERE email='$email' LIMIT 1");
if($value = $_SGLOBAL['db']->fetch_array($query)) {
$cid = $value['cid'];
} else {
$cid = inserttable('mailcron', array('email'=>$email), 1);
}
if($cid) {
//插入邮件内容队列
$setarr = array(
'cid' => $cid,
'subject' => "product invite",
'message' => "product invite",
'dateline' => $_SGLOBAL['timestamp']
);
inserttable('mailqueue', $setarr);
}
复制代码
2:使用source/do_sendmail.php发送邮件,ssetcookie('sendmail', '1', 300);//用户每5分钟调用本程序
ssetcookie('sendmail', '1', 300);//用户每5分钟调用本程序
$lockfile = S_ROOT.'./data/sendmail.lock';
@$filemtime = filemtime($lockfile);
if($_SGLOBAL['timestamp'] - $filemtime < 5) exit();
touch($lockfile);
//防止超时
set_time_limit(0);
//获取发送队列
$list = $sublist = $cids = $touids = array();
$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('mailcron')." WHERE sendtime<='$_SGLOBAL[timestamp]' ORDER BY sendtime LIMIT 0,$pernum");
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
if($value['touid']) $touids[$value['touid']] = $value['touid'];
$cids[] = $value['cid'];
$list[$value['cid']] = $value;
}
if(empty($cids)) exit();
//邮件内容
$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('mailqueue')." WHERE cid IN (".simplode($cids).")");
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
$sublist[$value['cid']][] = $value;
}
//开始发送
include_once(S_ROOT.'./source/function_sendmail.php');
foreach ($list as $cid => $value) {
$mlist = $sublist[$cid];
if($value['email'] && $mlist) {
$subject = getstr($mlist[0]['subject'], 80, 0, 0, 0, 0, -1);
$message = '';
foreach ($mlist as $subvalue) {
if($subvalue['message']) {
$message .= "<br><strong>$subvalue[subject]</strong><br>$subvalue[message]<br>";
} else {
$message .= $subvalue['subject'].'<br>';
}
}
if(!sendmail($value['email'], $subject, $message)) {
runlog('sendmail', "$value[email] sendmail failed.");
}
}
}
//检查是否存在当前队列
$cid = 0;
$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('mailcron')." WHERE email='$email' LIMIT 1");
if($value = $_SGLOBAL['db']->fetch_array($query)) {
$cid = $value['cid'];
} else {
$cid = inserttable('mailcron', array('email'=>$email), 1);
}
if($cid) {
//插入邮件内容队列
$setarr = array(
'cid' => $cid,
'subject' => "product invite",
'message' => "product invite",
'dateline' => $_SGLOBAL['timestamp']
);
inserttable('mailqueue', $setarr);
}
复制代码
2:使用source/do_sendmail.php发送邮件,ssetcookie('sendmail', '1', 300);//用户每5分钟调用本程序
ssetcookie('sendmail', '1', 300);//用户每5分钟调用本程序
$lockfile = S_ROOT.'./data/sendmail.lock';
@$filemtime = filemtime($lockfile);
if($_SGLOBAL['timestamp'] - $filemtime < 5) exit();
touch($lockfile);
//防止超时
set_time_limit(0);
//获取发送队列
$list = $sublist = $cids = $touids = array();
$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('mailcron')." WHERE sendtime<='$_SGLOBAL[timestamp]' ORDER BY sendtime LIMIT 0,$pernum");
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
if($value['touid']) $touids[$value['touid']] = $value['touid'];
$cids[] = $value['cid'];
$list[$value['cid']] = $value;
}
if(empty($cids)) exit();
//邮件内容
$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('mailqueue')." WHERE cid IN (".simplode($cids).")");
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
$sublist[$value['cid']][] = $value;
}
//开始发送
include_once(S_ROOT.'./source/function_sendmail.php');
foreach ($list as $cid => $value) {
$mlist = $sublist[$cid];
if($value['email'] && $mlist) {
$subject = getstr($mlist[0]['subject'], 80, 0, 0, 0, 0, -1);
$message = '';
foreach ($mlist as $subvalue) {
if($subvalue['message']) {
$message .= "<br><strong>$subvalue[subject]</strong><br>$subvalue[message]<br>";
} else {
$message .= $subvalue['subject'].'<br>';
}
}
if(!sendmail($value['email'], $subject, $message)) {
runlog('sendmail', "$value[email] sendmail failed.");
}
}
}
0 0
- uchome中的发送邮件
- UCHOME中配置邮件
- spring中的邮件发送
- Spring中的邮件发送配置
- SAP中的邮件发送功能
- java 邮件发送中的问题
- Android中的后台邮件发送
- yii框架中的邮件发送
- PHPMailer发送邮件中的坑
- BCB中的发送邮件的例子
- .Net 2.0 中的发送邮件实现小解
- spring 发送邮件中的乱码情况
- zend框架中的zend_mail 发送邮件
- 配置PHP中的mail方法发送邮件
- 配置PHP中的mail方法发送邮件
- 邮件发送
- 邮件发送
- 发送邮件
- ubuntu 安装 TM2009 QQ2013
- Android双向滑动菜单完全解析,教你如何一分钟实现双向滑动特效
- js去掉字符串前后空格的五种方法
- U3d学习第4天--u3d脚本代码基础判断和循环语句
- 验证码的功能实现
- uchome中的发送邮件
- ceph存储 loop设备及losetup命令介绍
- 数字图像处理基础知识总结
- RTP/RTCP协议介绍
- SharedPreferences清除问题
- Android PowerImageView实现,可以播放动画的强大ImageView
- ie11兼容性问题,jsp在IE11显示不全问题,ie11覆盖内容问题解决方法
- 导航栏的返回文字修改
- 关于树莓交叉编译Qt5