本文整理汇总了PHP中SendMail函数的典型用法代码示例。如果您正苦于以下问题:PHP SendMail函数的具体用法?PHP SendMail怎么用?PHP SendMail使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SendMail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verify
public function verify()
{
if (!IsGet('key') or !IsGet('sid')) {
$this->out('邮件验证参数非法!');
}
$key = ForceStringFrom('key');
$sid = ForceStringFrom('sid');
if (!$key or !$sid) {
$this->out('邮件验证参数非法!');
}
$email = base64_decode($key);
if (!IsEmail($email)) {
$this->out('Email地址非法!');
}
if (!($user = APP::$DB->getOne("SELECT u.aid, u.username, u.password, u.fullname, u.verifycode FROM " . TABLE_PREFIX . "admin u WHERE u.email = '{$email}' AND u.activated = 1"))) {
$this->out('Email地址不存在!');
} else {
$code = md5($user['fullname'] . WEBSITE_KEY . $user['password'] . $user['verifycode']);
if ($sid != $code) {
$this->out('链接请求的验证码错误!');
}
$newpass = PassGen(8);
$backend_url = BASEURL . ADMINDIR . '/';
$subject = '您的新密码 -- ' . APP::$_CFG['Title'];
$content = "{$user['fullname']}:<br><br>您好! <br><br>您的登录名是: {$user['username']}<br>您的新密码是:{$newpass}<br><br>";
$content .= "请点击以下链接登录后台管理:<br><br><a href=\"{$backend_url}\" target=\"_blank\">{$backend_url}</a><br><br>";
if (SendMail($email, $subject, $content) === true) {
//邮件发送成功后才更新用户密码, 清空验证码防止重复点击邮件中更新密码的链接
APP::$DB->exe("UPDATE " . TABLE_PREFIX . "admin SET password = '" . md5($newpass) . "', verifycode = '' WHERE aid = '{$user['aid']}'");
$this->out('新密码已发送到您的邮箱, 请查收!', 0);
} else {
$this->out('发送邮件失败! 请尝试刷新当前页面.');
}
}
}
示例2: promotion_pay_success_api
public function promotion_pay_success_api()
{
M('promotion')->where(array('submission_id' => I('submission_id'), 'promotion_code' => I('promotion_code')))->save(array('ispaied' => 1));
$email = M('email')->where(array('name' => '购买推广'))->find();
$email_content = $email['content'];
if (count(explode("\n", $email_content)) == 1) {
$email_content = explode("\r", $email_content);
} else {
$email_content = explode("\n", $email_content);
}
$temp = '';
foreach ($email_content as $key => $value) {
$temp .= $value . "<br/>";
}
$email_content = $temp;
$submission = M('submission')->where(array('id' => I('submission_id')))->find();
$tmp = '作品中文名称:' . $submission['titlec'] . '<br/>作品英文名称:' . $submission['titlee'] . '<br/>作品类别:' . $submission['category'];
$email_content = explode("^^^", $email_content);
$email_content = $email_content[0] . $tmp . $email_content[1];
$admins = M('user')->where(array('role' => 2))->select();
foreach ($admins as $key => $value) {
SendMail($value['email'], $email['title'], $email_content);
}
echo json_encode(array('submission_id' => I('submission_id'), 'promotion_code' => I('promotion_code')));
}
示例3: insert
function insert()
{
if (empty($_REQUEST['title'])) {
$this->error('项目名称不能为空!');
}
$name = $this->getActionName();
$model = D($name);
if (false === $model->create()) {
$this->error($model->getError());
}
//保存当前数据对象
$list = $model->add();
if ($list !== false) {
//保存成功
$proUser = M("ProjectsUser");
$proUser->user_id = $_REQUEST['creator'];
$proUser->project_id = $list;
$proUser->add();
if (!empty($_REQUEST['invite'])) {
import('@.ORG.Util.Mail');
$mailContent = '<p>Hi! ' . $_SESSION['userName'] . ' 邀请你一起参与' . $_REQUEST['title'] . '项目。</p><p>点击下面的链接,即可参与:</p><div> <a href="' . C('domain') . U('Public/join', array('id' => $list)) . '" target="_blank"> ' . C('domain') . U('Public/join', array('id' => $list)) . ' </a><div></div></div><p>如有问题,可与 ' . $_SESSION['userName'] . ' 联系: <a href="mailto:' . $_SESSION['email'] . '" target="_blank">' . $_SESSION['email'] . '</a></p>';
$mailArr = explode(',', $_REQUEST['invite']);
foreach ($mailArr as $k => $v) {
SendMail($v, $_REQUEST['title'] . ' 项目成员邀请函', $mailContent, 'IT项目实验室(QQ群:273950048)');
}
}
$this->success('创建成功!', cookie('_currentUrl_'));
} else {
//失败提示
$this->error('创建失败!');
}
}
示例4: send_email_ajax_res
public function send_email_ajax_res()
{
//import('.ORG.Mail');//引入发送邮件类
//由于这里的文件加载使用import出现错误,所以在这里应用的require的加载方式
require_once './Component/Mail.class.php';
//SendMail('目标地址','邮件标题','正文','发件人');//发送邮件类具体参数
$target_address = $_POST['target_address'];
$email_title = $_POST['email_title'];
$email_content = $_POST['email_content'];
// $send_person="postmaster@lovedraem.com";//这是我的测试网站的名称
$send_person = "爱做梦-数据监控平台-徐宁";
if (empty($target_address) && empty($email_title) && empty($email_content)) {
echo "邮件不完整!";
} else {
$email_reslt = SendMail($target_address, $email_title, $email_content, $send_person);
if ($email_reslt == 1) {
$email_bd_obg = D('Emails');
$email_bd_obg->geter = $target_address;
$email_bd_obg->title = $email_title;
$email_bd_obg->content = $email_content;
$email_bd_obg->sendtime = date("y-m-d", time());
$add_email_res = $email_bd_obg->add();
//这里添加完成之后就不在给予任何的提示
echo "发送成功!";
} else {
echo "发送失败!";
}
}
}
示例5: sendEmailHandler
/**
* 发送验证邮件
* @param string $to 收信人
*/
public function sendEmailHandler()
{
//后台再来一遍验证呀
if (!preg_match("/^([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+\$/", $this->_post('email'))) {
$this->ajaxReturn(3, "邮箱格式不正确", 1);
return;
}
$email = $this->_post('email');
//验证邮箱唯一性
$f = $this->checkEmailUnique();
if (!$f) {
return;
}
$vld_url = $this->buildUrl($email);
$title = "小蜜蜂兼职";
$message = <<<EOT
\t\t您的邮箱为:{$email},
\t\t您的验证码为:{$vld_url}
EOT;
if (SendMail($email, $title, $message)) {
//设置session
session('email_ver', $verify);
session('email', $email);
$this->ajaxReturn(1, "发送成功", 1);
} else {
$this->ajaxReturn(0, "发送失败", 1);
}
}
示例6: runemail
public function runemail()
{
$emailsys = M('sys')->where(array('sys_id' => 1))->find();
$config = array('MAIL_FROM' => $emailsys['email_name'], 'MAIL_HOST' => $emailsys['email_smtpname'], 'MAIL_USERNAME' => $emailsys['email_emname'], 'MAIL_FROMNAME' => $emailsys['email_rename'], 'MAIL_PASSWORD' => $emailsys['email_pwd']);
if ($emailsys['email_open'] == 1) {
//邮件发送开关
$config['MAIL_SMTPAUTH'] = TRUE;
} else {
$config['MAIL_SMTPAUTH'] = FALSE;
}
C($config);
$admin = M('admin')->where(array('admin_email' => I('email')))->find();
if (!$admin) {
$this->error('邮件不存在,请重新输入', 0, 0);
}
$oldnum = rand(10000, 99999);
//获取一串随机数
$num = md5($oldnum);
//对随机数进行加密后传递
$emailpwd = M('admin')->where(array('admin_email' => I('email')))->setField('admin_mdemail', $num);
//更新数据库
$content = "尊敬的用户,您好:<br>您当前的操作为找回密码,请点击以下链接重新设置密码<br><a href=http://127.0.0.1/newadmin/index.php/Admin/Login/checkpwd/emailpwd/{$num}.html>http://127.0.0.1/newadmin/index.php/Admin/Login/checkpwd/emailpwd/{$num}.html</a>";
if (SendMail($_POST['email'], '找回密码服务', $content)) {
$this->success('邮件发送成功!,打开邮件重新设置密码', 1, 1);
} else {
$this->error('邮件发送失败', 0, 0);
}
}
示例7: txReportAdd
function txReportAdd()
{
global $DB, $C, $L, $t, $domain;
$gallery = $DB->Row('SELECT * FROM `tx_galleries` WHERE `gallery_id`=?', array($_REQUEST['id']));
$v = new Validator();
$v->Register($_REQUEST['reason'], V_EMPTY, sprintf($L['REQUIRED_FIELD'], $L['REPORT']));
if (!$gallery) {
$v->SetError($L['BAD_GALLERY_ID']);
}
if ($C['report_captcha']) {
VerifyCaptcha($v);
}
if (!$v->Validate()) {
return $v->ValidationError('txShReportAdd', TRUE);
}
$DB->Update('INSERT INTO `tx_reports` VALUES (?,?,?,?,?)', array(null, $gallery['gallery_id'], $_SERVER['REMOTE_ADDR'], MYSQL_NOW, $_REQUEST['reason']));
$_REQUEST['report_id'] = $DB->InsertID();
$t->assign_by_ref('report', $_REQUEST);
$t->display($domain['template_prefix'] . 'report-complete.tpl');
flush();
// See if we need to e-mail any administrators
$reports_waiting = $DB->Count('SELECT COUNT(*) FROM `tx_reports`');
$t->assign('reports_waiting', $reports_waiting);
$administrators =& $DB->FetchAll('SELECT * FROM `tx_administrators`');
foreach ($administrators as $administrator) {
if ($administrator['reports_waiting'] > 0) {
if ($administrator['notifications'] & E_CHEAT_REPORT && $reports_waiting % $administrator['reports_waiting'] == 0) {
SendMail($administrator['email'], 'email-admin-reports.tpl', $t);
}
}
}
}
示例8: j_email
public function j_email()
{
// 如果
if (isset($_POST['em'])) {
$email = $_POST['em'];
$account_model = D('Account');
// 证明已经注册过
if ($account_model->judge_account_id_isset($email)) {
Response::show('-101', '该邮箱已经被注册!');
} else {
// 发送给用户的信息
$rand_string = strtolower(rand_string());
$title = '欢迎您注册!么么哒。';
$content = '您好,您的注册验证码是 : ' . $rand_string . ' !, 如果不是本人操作,请忽略!';
$Memcached = Memcached::getInstance();
// 暂时不加密了。
$Memcached->set($email, $rand_string);
if (SendMail($email, $title, $content) === true) {
Response::show('200', '已经发送验证码,请注意查收!');
} else {
Log::write('发送验证码失败,to [--' . $email . '--]', 'WARN');
Response::show('-102', '邮件发送失败,未知原因!');
}
}
}
Response::show('-103', '数据丢失!');
}
示例9: Test_email
public function Test_email()
{
echo "<h1>测试发送邮件</h1>";
import('.ORG.Mail');
//引入发
// SendMail('目标地址','邮件标题','正文','发件人');
$target_address = $_POST['target_address'];
$email_title = $_POST['email_title'];
$email_content = $_POST['email_content'];
$send_person = "postmaster@lovedraem.com";
if (empty($target_address) && empty($email_title) && empty($email_content)) {
$this->display();
} else {
$email_reslt = SendMail($target_address, $email_title, $email_content, $send_person);
if ($email_reslt == 1) {
/**
* 测试保留
* echo "<br/>".$target_address;
echo "<br/>".$email_title;
echo "<br/>".$email_content;
echo "<br/>".$send_person;
*/
$this->redirect("email_successful");
} else {
$this->redirect("email_error");
}
}
}
示例10: add
public function add()
{
if (SendMail($_POST['mail'], $_POST['title'], $_POST['content'])) {
$this->success('发送成功!');
}
//else
//$this->error('发送失败');
}
示例11: SendMailByNetid
function SendMailByNetid($netid, $subject, $msg)
{
$netid_suffix = array("@mail2.sysu.edu.cn", "@mail.sysu.edu.cn", "@student.sysu.edu.cn");
foreach ($netid_suffix as $suffix) {
SendMail($netid . $suffix, $subject, $msg);
}
return 0;
}
示例12: register
public function register($username = "", $password = "", $repassword = "", $email = "", $verify = "")
{
if (!C("USER_ALLOW_REGISTER")) {
$this->error("注册已关闭");
}
if (IS_POST) {
//注册用户
/* 检测验证码 */
//if(!check_verify($verify)){
//$this->error("验证码输入错误!");
//}
/* 检测密码 */
if ($password != $repassword) {
$this->error("密码和重复密码不一致!");
}
/* 调用注册接口注册用户 */
$User = new UserApi();
//返回ucentermember数据表用户主键id
$uid = $User->register($username, $password, $email);
if (0 < $uid) {
//注册成功
//TODO: 发送验证邮件
// 配置邮件提醒
$mail = $_POST['email'];
//获取会员邮箱
$title = "注册提醒";
$content = "您在<a href=\"" . C('DAMAIN') . "\" target='_blank'>" . C('SITENAME') . '</a>注册了账号,请点击激活' . $mail;
if (C('MAIL_PASSWORD')) {
SendMail($mail, $title, $content);
}
// 调用登陆
$this->login($username, $password);
} else {
//注册失败,显示错误信息
$this->error($this->showRegError($uid));
}
} else {
$menu = R("index/menulist");
/* 购物车调用*/
$cart = R("shopcart/usercart");
$this->assign("usercart", $cart);
if (!session("user_auth")) {
$usercart = $_SESSION["cart"];
$this->assign("usercart", $usercart);
}
/* 热词调用*/
$hotsearch = R("Index/getHotsearch");
$this->assign("hotsearch", $hotsearch);
$this->assign("categoryq", $menu);
//显示注册表单
$this->display();
}
}
示例13: register
public function register($username = "", $password = "", $repassword = "", $email = "", $verify = "")
{
$username = safe_replace($username);
//过滤
if (!C("USER_ALLOW_REGISTER")) {
$this->error("注册已关闭");
}
if (IS_POST) {
//注册用户
/* 检测验证码 */
//if(!check_verify($verify)){
//$this->error("验证码输入错误!");
//}
/* 检测密码 */
if ($password != $repassword) {
$this->error("密码和重复密码不一致!");
}
/* 调用注册接口注册用户 */
$User = new UserApi();
//返回ucentermember数据表用户主键id
$uid = $User->register($username, $password, $email);
if (0 < $uid) {
//注册成功
//TODO: 发送验证邮件
// 配置邮件提醒
$mail = I('post.email');
// 过滤$_POST['email'];//获取会员邮箱
$title = "注册提醒";
$auth = sha1(C('DATA_AUTH_KEY'));
$url = $_SERVER['SERVER_NAME'] . U("account/confirm_email", array('regid' => $uid, 'type' => "email", 'auth' => $auth, 'url' => $_SERVER['SERVER_NAME']));
$words = sha1($url);
$content = "您在" . C('SITENAME') . "注册了账号,<a href=\"" . $url . "\" target='_blank'>" . $words . '</a>请点击激活' . $mail;
//记录日志
addUserLog('新会员注册', $uid);
if (C('MAIL_PASSWORD')) {
SendMail($mail, $title, $content);
}
// 调用登陆
$this->login($username, $password);
} else {
//注册失败,显示错误信息
$this->error($this->showRegError($uid));
}
} else {
$this->meta_title = '会员注册';
$this->display();
}
}
示例14: BulkMail
function BulkMail()
{
global $C, $DB;
$message = GetValue('bulk_email');
$t = new Template();
$t->assign_by_ref('config', $C);
$result = $DB->Query('SELECT * FROM `tlx_accounts` JOIN `tlx_account_fields` USING (`username`)');
while ($account = $DB->NextRow($result)) {
if ($account['status'] == STATUS_ACTIVE) {
$t->assign_by_ref('account', $account);
SendMail($account['email'], $message, $t, FALSE);
}
}
$DB->Free($result);
DeleteValue('bulk_email');
}
示例15: Entry
function Entry()
{
$inputMail = CgiInput("mail", "");
$inputReturnPage = CgiInput("return_page", "");
if ($inputMail == "") {
CgiOutput(__LINE__, "mail cannot be empty");
}
if (LoginGetUser() != "") {
CgiOutput(__LINE__, "already login");
}
$validateKey = LoginGetValidateKey($inputMail);
if (SendMail($inputMail, $validateKey, $inputReturnPage)) {
CgiOutput(__LINE__, "send mail failed");
}
CgiOutput(0, "");
}