ecshop新会员注册邮件提醒管理员

第一步:商店设置 添加 邮件设置

1、ecs_mail_templates表插入一条新会员注册邮件提醒模板数据

INSERT INTO ecs_mail_templates (template_id, template_code, is_html, template_subject, template_content, last_modify, last_send, type) VALUES(16, 'remind_of_new_reg', 1, '新会员注册提醒', '<p>亲爱的管理员,您好:<br /><br />快来看看吧,{$shop_name}又有新会员注册了。<br /><br />-----------------------------------------------------------------<br /><br />会员:{$user_name} <br /><br />邮箱:{$email}<br /><br />{$shop_name}小秘书提醒<br /><br />{$send_date}</p>', 1330402034, 0, 'template');

2、在商店设置的“WAP设置”选项卡的位置旁边增加选项卡“邮件设置”

INSERT INTO ecs_shop_config (id, parent_id, code, type, store_range, store_dir, value, sort_order) VALUES (10, 0, email, group, '', '', '', 1);
INSERT INTO ecs_shop_config (id, parent_id, code, type, store_range, store_dir, value, sort_order) VALUES (1001, 10, send_reg_email, select, 1,0, '', 1, 1);

3、把客服邮件地址放置到刚刚建好的“邮件设置”选项卡里来

UPDATE ecs_shop_config SET id = 1002,parent_id = 10 WHERE ecs_shop_config.id =114;	//WHERE code="service_email";

4、增加语言

1) /languages/zh_cn/admin/mail_template.php 中添加:

/* 模板描述 */
$_LANG['remind_of_new_reg'] = '新会员注册提醒模板';

2) /languages/zh_cn/admin/shop_config.php 中添加:

$_LANG['cfg_desc']['service_email'] = '用于接收新订单提醒、新会员注册提醒等商城运营邮件,多个邮箱请用英文逗号分隔。';
$_LANG['cfg_name']['send_reg_email'] = '新会员注册时是否给管理员发送邮件';
$_LANG['cfg_range']['send_reg_email']['0'] = '不发送邮件';
$_LANG['cfg_range']['send_reg_email']['1'] = '发送邮件';
$_LANG['cfg_desc']['send_service_email'] = "商城信息中的客服邮件地址或管理员邮件地址不为空时,该选项有效。";

效果图:

ecshop1

第二步,填写ecshop后台->邮件服务器设置 和 为该邮箱开启POP3/SMTP服务

QQ图片20131224142731 QQ图片20131224143035

第三步:增加PHP处理逻辑

flow.php和user.php中均有会员注册逻辑,所以这两个文件都要增加邮件提醒代码

flow.php 大概287行:

if (register(trim($_POST['username']), trim($_POST['password']), trim($_POST['email'])))
{
	/* 用户注册成功 */
	ecs_header("Location: flow.php?step=consigneen");
	exit;
}

修改为:

if (register(trim($_POST['username']), trim($_POST['password']), trim($_POST['email'])))
{
	/* 用户注册成功,如果需要,发邮件给管理员 */
	if ($GLOBALS['_CFG']['send_reg_email'] == '1')
	{
		$tpl = get_mail_template('remind_of_new_reg');
		$smarty->assign('shop_name', $_CFG['shop_name']);
		$smarty->assign('send_date', date($_CFG['time_format']));
		$smarty->assign('user_name', trim($_POST['username']));
		$smarty->assign('email', trim($_POST['email']));
		$content = $smarty->fetch('str:' . $tpl['template_content']);
		if($_CFG['service_email'] != '')
		{
			//ECSHOP默认不支持多个邮件发送,将逗号分隔的邮件地址分解成数组,再循环逐个发送。
			$arrEmail = explode("," ,$_CFG['service_email']);
			foreach($arrEmail as $arrEmailValue)
			{
				send_mail($_CFG['shop_name'], $arrEmailValue, $tpl['template_subject'], $content, $tpl['is_html']); //发给管理员
			}
		}                    
	}
	ecs_header("Location: flow.php?step=consigneen");
	exit;
}

user.php 大概在261行下面加入:

/* 用户注册成功,如果需要,发邮件给管理员 */
if ($GLOBALS['_CFG']['send_reg_email'] == '1')
{	
	$tpl = get_mail_template('remind_of_new_reg');
	$smarty->assign('shop_name', $_CFG['shop_name']);
	$smarty->assign('send_date', date($_CFG['time_format']));
	$smarty->assign('user_name', trim($_POST['username']));
	$smarty->assign('email', trim($_POST['email']));
	$content = $smarty->fetch('str:' . $tpl['template_content']);
	if($_CFG['service_email'] != '')
	{
		//ECSHOP默认不支持多个邮件发送,将逗号分隔的邮件地址分解成数组,再循环逐个发送。
		$arrEmail = explode("," ,$_CFG['service_email']);
		foreach($arrEmail as $arrEmailValue)
		{
			send_mail($_CFG['shop_name'], $arrEmailValue, $tpl['template_subject'], $content, $tpl['is_html']); //发给管理员
		}
	}                    
}

最终效果:

send_email

阅读剩余
THE END