function send_email($email, $subject, $template, $ip, $a_origin, $a_dest, $instant_deliver = true) { $errno = can_send_to($email, $ip); if ($errno != 0) { return $errno; } $smtpemailto = $email; //send to whom $subject = $subject; //subject $content = file_get_contents($template); if (count($a_origin) != count($a_dest)) { return 4; } for ($i = 0; $i < count($a_origin); $i++) { $content = str_replace($a_origin[$i], $a_dest[$i], $content); } $smtp = new Smtp(SMTPSERVER, SMTPSERVERPORT, true, SMTPUSER, SMTPPASS); //这里面的一个true是表示使用身份验证,否则不使用身份验证. $smtp->debug = false; //是否显示发送的调试信息 if ($smtp->sendmail($smtpemailto, SMTPUSERMAIL, $subject, $content, MAILTYPE)) { return 0; } else { return 3; } }
static function sendEmail($subject="",$content="",$to=array()) { $emailuser = $info['emailuser']; $emailpassword = $info['emailpassword']; $smtpserver = C('email_server'); $port = C('email_port'); $smtpuser = C('email_user'); $smtppwd = C('email_pwd'); $mailtype = "TXT"; $sender = C('email_user'); $smtp = new Smtp($smtpserver,$port,true,$smtpuser,$smtppwd,$sender); $subject = $subject; $body = $content; $to = implode(",", $to); //$body = iconv('UTF-8','gb2312',$fetchcontent);inv $send=$smtp->sendmail($to,$sender,$subject,$body,$mailtype); }
public function registerAction() { if ($_POST) { $man = new user(); $data = array('Email' => $this->getRequest()->getParam('Email', ''), 'password' => $this->getRequest()->getParam('password', ''), 'nickname' => $this->getRequest()->getParam('username', ''), 'institute' => $this->getRequest()->getParam('institute', ''), 'grade' => $this->getRequest()->getParam('grade', ''), 'sex' => $this->getRequest()->getParam('sex', ''), 'verify' => md5($this->getRequest()->getParam('username', '') . md5($this->getRequest()->getParam('password', '')) . time())); $result = $man->isEmailExist($data['Email']); if ($result == true) { echo '<script>alert("邮箱已存在,请换个其他的邮箱");window.history.go(-1);</script>'; exit; } $result = $man->insertUser($data); include_once "smtp.class.php"; $smtpserver = "smtp.163.com"; //SMTP服务器 $smtpserverport = 25; //SMTP服务器端口 $smtpusermail = "*****@*****.**"; //SMTP服务器的用户邮箱 $smtpuser = "******"; //SMTP服务器的用户帐号 $smtppass = "******"; //SMTP服务器的用户密码 $smtp = new Smtp($smtpserver, $smtpserverport, true, $smtpuser, $smtppass); //这里面的一个true是表示使用身份验证,否则不使用身份验证. $emailtype = "HTML"; //信件类型,文本:text;网页:HTML $smtpemailto = $data['Email']; $smtpemailfrom = $smtpusermail; $emailsubject = "用户帐号激活"; $emailbody = "亲爱的" . $data['nickname'] . ":<br/>感谢您在MicrowKnow注册了新帐号。<br/>请点击链接激活您的帐号。<br/><a href='http://localhost/Account/active?verify=" . $data['verify'] . "' target='_blank'>http://localhost/account/active?verify=" . $data['verify'] . "</a><br/>如果以上链接无法点击,请将它复制到你的浏览器地址栏中进入访问,该链接24小时内有效。<br/>如果此次激活请求非你本人所发,请忽略本邮件。<br/><p style='text-align:right'>-------- 武汉大学微软技术俱乐部 敬上</p>"; $rs = $smtp->sendmail($smtpemailto, $smtpemailfrom, $emailsubject, $emailbody, $emailtype); //$this->view->info='恭喜您,注册成功!<br/>请登录到您的邮箱及时激活您的帐号!'; $this->forward('login', 'index'); } else { $this->render('register'); } }
function sendmail($time, $email, $url) { include_once "smtp.class.php"; $smtpserver = "smpt.126.com"; //SMTP服务器 $smtpserverport = 25; //SMTP服务器端口 $smtpusermail = "*****@*****.**"; //SMTP服务器的用户邮箱 $smtpuser = "******"; //SMTP服务器的用户帐号 $smtppass = "******"; //SMTP服务器的用户密码 $smtp = new Smtp($smtpserver, $smtpserverport, true, $smtpuser, $smtppass); //这里面的一个true是表示使用身份验证,否则不使用身份验证. $emailtype = "HTML"; //信件类型,文本:text;网页:HTML $smtpemailto = $email; $smtpemailfrom = $smtpusermail; $emailsubject = "NCTF - 找回密码"; $emailbody = "亲爱的" . $email . ":<br/>您交了找回密码请求。请点击下面的链接重置密码。<br/><a href='" . $url . "' target='_blank'>" . $url . "</a><br/>如果以上链接无法点击,请将它复制到你的浏览器地址栏中进入访问。<br/>如果您没有提交找回密码请求,请忽略此邮件。"; $rs = $smtp->sendmail($smtpemailto, $smtpemailfrom, $emailsubject, $emailbody, $emailtype); return $rs; }
function sendmail($time, $email, $url) { include_once "smtp.class.php"; $smtpserver = "smtp.163.com"; //SMTP服务器 $smtpserverport = 25; //SMTP服务器端口 $smtpusermail = "*****@*****.**"; //SMTP服务器的用户邮箱 $smtpuser = "******"; //SMTP服务器的用户帐号 $smtppass = ""; //SMTP服务器的用户密码 $smtp = new Smtp($smtpserver, $smtpserverport, true, $smtpuser, $smtppass); //这里面的一个true是表示使用身份验证,否则不使用身份验证. $emailtype = "HTML"; //信件类型,文本:text;网页:HTML $smtpemailto = $email; $smtpemailfrom = $smtpusermail; $emailsubject = "素材火sucaihuo.com - 找回密码"; $emailbody = "亲爱的" . $email . ":<br/>您在" . $time . "提交了找回密码请求。请点击下面的链接重置密码(按钮24小时内有效)。<br/><a href='" . $url . "' target='_blank'>" . $url . "</a><br/>如果以上链接无法点击,请将它复制到你的浏览器地址栏中进入访问。<br/>如果您没有提交找回密码请求,请忽略此邮件。"; $rs = $smtp->sendmail($smtpemailto, $smtpemailfrom, $emailsubject, $emailbody, $emailtype); return $rs; }
function sendEmail($code) { $smtp = new Smtp("smtp.qq.com", "25", true, "719193930", "hyd123456"); $smtp->debug = FALSE; $smtp->sendmail($_SESSION["email"], "*****@*****.**", "vcanbuy_test", $this->mailMessage($code), "HTML"); }
function add() { if (!IS_POST) { $this->error(L('operation_failure')); exit; } $diyid = $this->_post('diyid'); $diyinfo = D('diyform')->get_diyform($diyid); if (!$diyinfo) { $this->error(sprintf(L('not_exist'), L('diyform'))); exit; } if ($diyinfo['status'] == 0) { $this->error(sprintf(L('not_exist'), L('diyform'))); exit; } $data = $_POST['addfields']; $fields = D('model_fields')->get_fields($diyid, array('mtype' => 2)); $mod = D('diyform_list'); $LastInsID = false; foreach ($data as $k => $v) { if (array_key_exists($k, $fields)) { $error = $fields[$k]['errortips']; //检测是否为空 if ($fields[$k]['required'] == 1 && empty($data[$k])) { if (!$error) { $error = sprintf(L('field_required'), $fields[$k]['name']); } $this->error($error); } //验证限制格式 if ($fields[$k]['verification']) { if (!preg_match("/{$fields[$k]['verification']}/", $v)) { if (!$error) { $error = sprintf(L('format_error'), $fields[$k]['name']); } $this->error($error); } } //验证限制格式 //转换数据 if (is_array($v)) { $v = join('|||', $v); } //转换数据end //主表 if ($LastInsID === false) { $this->save($mod, array('diyid' => $diyid, 'uid' => 0, 'status' => 1)); $LastInsID = $mod->getLastInsID(); } //附加表 if ($LastInsID) { D('model_fields')->save_fields($LastInsID, array('fieldsid' => $k, 'info' => $v, 'modelid' => $diyid), 2); } } } // end foreach //发送邮件 if ($diyinfo['sendmail']) { //邮箱配置 $mailconfig = C('email'); $smtpserver = $mailconfig['smtpserver']; $smtpserverport = $mailconfig['smtpserverport']; $smtpuser = $mailconfig['smtpuser']; $smtppass = $mailconfig['smtppass']; if ($smtpserver && $smtpserverport && $smtpuser && $smtppass) { $smtpemailto = $diyinfo['toemail']; $mailsubject = $diyinfo['title'] . ' - ' . C('sys_sitename'); //邮件主题 $mailbody = '主人,您的网站有人留言了,赶紧去看看是谁吧!<br><br><a href="' . C('sys_siteurl') . '" target="_blank">' . C('sys_siteurl') . '</a><br><br>发送时间:' . date('Y年m月d日 H时:i分', time()); $mailtype = "HTML"; //邮件格式(html/txt),txt为文本邮件 $smtp = new Smtp($smtpserver, $smtpserverport, true, $smtpuser, $smtppass); //这里面的一个true是表示使用身份验证,否则不使用身份验证. $smtp->debug = false; //是否显示发送的调试信息 $smtp->sendmail($smtpemailto, $smtpuser, $mailsubject, $mailbody, $mailtype); } } unset($LastInsID); unset($data); unset($fields); $this->success(L('add_ok')); }
public function checkpwd() { $where['username'] = $this->_post('username'); $where['email'] = $this->_post('email'); $db = D('Users'); $list = $db->where($where)->find(); if ($list == false) { $this->error('邮箱和帐号不正确', U('Index/regpwd')); } $smtpserver = C('email_server'); $port = C('email_port'); $smtpuser = C('email_user'); $smtppwd = C('email_pwd'); $mailtype = "TXT"; $sender = C('email_user'); $smtp = new Smtp($smtpserver, $port, true, $smtpuser, $smtppwd, $sender); $to = $list['email']; $subject = C('pwd_email_title'); $code = C('site_url') . U('Index/resetpwd', array('uid' => $list['id'], 'code' => md5($list['id'] . $list['password'] . $list['email']), 'resettime' => time())); $fetchcontent = C('pwd_email_content'); $fetchcontent = str_replace('{username}', $where['username'], $fetchcontent); $fetchcontent = str_replace('{time}', date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']), $fetchcontent); $fetchcontent = str_replace('{code}', $code, $fetchcontent); $body = $fetchcontent; //$body = iconv('UTF-8','gb2312',$fetchcontent);inv $send = $smtp->sendmail($to, $sender, $subject, $body, $mailtype); $this->success('请访问你的邮箱 ' . $list['email'] . ' 验证邮箱后登录!<br/>'); }
/* close statement */ mysqli_stmt_close($stmt); } if ($tag) { $userid = $id; $str = strval(rand(0, 999999)); $newStr = sprintf('%06s', $str); $e = time() + 60 * 15; $tag1 = mysqli_query($conn, "UPDATE email_code SET exp_time = '0' WHERE userid = '{$userid}'"); $tag2 = mysqli_query($conn, "INSERT INTO email_code (userid,code,exp_time) VALUES ('{$userid}','{$newStr}','{$e}')"); if ($tag1 && $tag2) { $smtpserver = "smtp.163.com"; $smtpserverport = 25; $smtpusermail = "*****@*****.**"; $smtpuser = "******"; $smtppass = "******"; $smtp = new Smtp($smtpserver, $smtpserverport, true, $smtpuser, $smtppass); $emailtype = "HTML"; $smtpemailto = $email; $smtpemailfrom = $smtpusermail; $emailsubject = "用户帐号激活"; $emailbody = "您的验证码是" . $newStr . ",请于15分钟内进行认证。若非本人操作请忽略。【timedia】"; $rs = $smtp->sendmail($smtpemailto, $smtpemailfrom, $emailsubject, $emailbody, $emailtype); if ($rs == 1) { $msg = 1; } else { $msg = 0; } } echo $msg; }
public function sendMail() { if (isset($_POST['btnSend'])) { $email = stripslashes(trim($_POST['email'])); //$email = stripslashes(trim($_GET['mail'])); //$email = injectChk($email);//防止注入 $this->load->model("User_model"); $user = $this->User_model->user_select($email); if (count($user) <= 0) { //该邮箱尚未注册! echo '未注册!'; //$msg = "noreg"; //exit; } else { date_default_timezone_set("Asia/Shanghai"); //设定时区东八区 $getpasstime = time(); $uid = $user[0]->id; $token = md5($uid . $user[0]->user_name . $user[0]->password); $url = "http://localhost/paperassist/index.php/reset?email=" . $email . "&token=" . $token; $time = date('Y-m-d H:i'); //$result = sendmail($time,$email,$url); include_once "Smtp.php"; $smtpserver = "smtp.qq.com"; //SMTP服务器 $smtpserverport = 25; //SMTP服务器端口 $smtpusermail = "*****@*****.**"; //SMTP服务器的用户邮箱 $smtpuser = "******"; //SMTP服务器的用户帐号 //$smtpuser = ""; //SMTP服务器的用户帐号 $smtppass = "******"; //SMTP服务器的用户密码 $smtp = new Smtp($smtpserver, $smtpserverport, true, $smtpuser, $smtppass); //这里面的一个true是表示使用身份验证,否则不使用身份验证. $emailtype = "HTML"; //信件类型,文本:text;网页:HTML $smtpemailto = $email; $smtpemailfrom = $smtpusermail; $emailsubject = "PaperAssist.com - 找回密码(请不要回复此邮件)"; $emailbody = "亲爱的" . $email . ":<br/>您在" . $time . "提交了找回密码请求。请点击下面的链接重置密码(按钮24小时内有效)。<br/><a href='" . $url . "' target='_blank'>" . $url . "</a><br/>如果以上链接无法点击,请将它复制到你的浏览器地址栏中进入访问。<br/>如果您没有提交找回密码请求,请忽略此邮件。"; $result = $smtp->sendmail($smtpemailto, $smtpemailfrom, $emailsubject, $emailbody, $emailtype); if ($result == 1) { //邮件发送成功 $msg = '系统已向您的邮箱发送了一封邮件<br/>请登录到您的邮箱及时重置您的密码!'; //更新数据发送时间 //mysql_query("update user set getpasstime ='$getpasstime' where id='$uid '"); $this->User_model->updatePasstime($uid, $getpasstime); } else { //$msg = $result; $msg = '邮件发送失败!'; } echo $msg; } } }
public function findpassAction() { // 读取配置参数 $this->view->disable(); $filename = __DIR__ . "/../config/settings.json"; if (file_exists($filename)) { $fs = fopen($filename, "r"); $file = fread($fs, filesize($filename)); fclose($fs); if ($fs != null || $file != "") { $settings = json_decode($file); } else { $this->flash->error("邮件发送服务未配置"); } } else { $this->flash->error("邮件发送服务未配置"); $this->response->redirect('managerlogin'); return; } $url = $_SERVER['SERVER_NAME']; $host = $settings->host; $from = $settings->from; $username = $settings->username; $password = $settings->password; if ($from == "" || is_null($from)) { $from = $username; } // 向指定邮箱发一封邮件 // 内含用户名 // 密码重置链接 if ($this->request->isPost() == true) { $email = $this->request->getPost('email', 'email'); $manager = Manager::findFirst(array('email=:e:', 'bind' => array('e' => $email))); if ($manager == false) { $this->flash->error('找不到该用户'); $this->response->redirect('managerlogin'); return; } $id = $manager->id; $name = $manager->name; $user = $manager->username; $pass = $manager->password; // 迷之加密方法 $a = $this->encrypt($id, $this->something); $b = $this->encrypt($user, $pass); // 这里要对url进行拼接,不带有http开头的链接并不能被邮件客户端正确识别 $url = "http://" . $url; $url .= "/managerlogin/resetpassword?a=" . $a . "&b=" . $b; $smtp = new Smtp($host, 25, true, $username, $password); $subject = "Question在线答题系统重置密码"; $body = "<h3>找回密码</h3><p>尊敬的{$name}:<br>您的用户名为:{$user}<br>请点击以下链接进行密码重置操作:<a href=\"{$url}\">{$url}</a>"; // $this->flash->error($host.$username.$password.$name.$user.$email.$from.$subject.$body); $issend = $smtp->sendmail($email, $from, $subject, $body, "HTML"); if ($issend == true) { $this->flash->success('成功发送邮件,请查收'); } else { $this->flash->error('邮件发送失败,请您联系管理员'); } $this->response->redirect('managerlogin'); } }
public static function ordermaill($maillto, $title, $content) { $configModel = new Model_Sysconfig(); $configs = $configModel->getConfig(0); //如果没有自定义SMTP配置 if ($configs['cfg_mail_smtp'] == '') { $configs['cfg_mail_smtp'] = "smtp.163.com"; } if ($configs['cfg_mail_port'] == '') { $configs['cfg_mail_port'] = 25; } if ($configs['cfg_mail_user'] == '') { $configs['cfg_mail_user'] = "******"; $configs['cfg_mail_pass'] = "******"; } $smtpserver = $configs['cfg_mail_smtp']; //SMTP服务器 $smtpserverport = $configs['cfg_mail_port']; //SMTP服务器端口 $smtpusermail = $configs['cfg_mail_user']; //SMTP服务器的用户邮箱 $smtpemailto = $maillto; //发送给谁 $smtpuser = $configs['cfg_mail_user']; //SMTP服务器的用户帐号 $smtppass = $configs['cfg_mail_pass']; //SMTP服务器的用户密码 $mailtype = "HTML"; //邮件格式(HTML/TXT),TXT为文本邮件 ########################################## if ($smtpserverport == 25) { $mailsubject = iconv('UTF-8', 'GB2312//IGNORE', $title); //邮件主题 $mailbody = iconv('UTF-8', 'GB2312//IGNORE', $content); //邮件内容 $smtp = new Smtp($smtpserver, $smtpserverport, true, $smtpuser, $smtppass); //这里面的一个true是表示使用身份验证,否则不使用身份验证. $smtp->debug = false; //是否显示发送的调试信息 $status = $smtp->sendmail($smtpemailto, $smtpuser, $mailsubject, $mailbody, $mailtype); } else { $mail = new Mysendmail(); $mail->setServer($smtpserver, $smtpuser, $smtppass, 465, true); //设置smtp服务器,到服务器的SSL连接 $mail->setFrom($smtpuser); //设置发件人 $mail->setReceiver($smtpemailto); //设置收件人,多个收件人,调用多次 $mail->setMail($title, $content); //设置邮件主题、内容 $status = $mail->sendMail(); //发送 } return $status; }