Пример #1
0
 function test_sendmail()
 {
     $site_config = array();
     $site_config['email_type'] = IReq::get('email_type');
     $site_config['mail_address'] = IReq::get('mail_address');
     $site_config['smtp'] = IReq::get('smtp');
     $site_config['smtp_user'] = IReq::get('smtp_user');
     $site_config['smtp_pwd'] = IReq::get('smtp_pwd');
     $site_config['smtp_port'] = IReq::get('smtp_port');
     $site_config['email_safe'] = IReq::get('email_safe');
     $test_address = IReq::get('test_address');
     $smtp = new SendMail($site_config);
     if ($error = $smtp->getError()) {
         $result = array('isError' => true, 'message' => $error);
     } else {
         $title = 'email test';
         $content = 'success';
         if ($smtp->send($test_address, $title, $content)) {
             $result = array('isError' => false, 'message' => '恭喜你!测试通过');
         } else {
             $result = array('isError' => true, 'message' => '测试失败,请确认您的邮箱已经开启的smtp服务并且配置信息均填写正确');
         }
     }
     echo JSON::encode($result);
 }
Пример #2
0
 public function main()
 {
     // 发送者
     $fromAddress = 'CleverCode<*****@*****.**>';
     // 接收者
     $toAddress = '*****@*****.**';
     // 标题
     $subject = '这里是标题!';
     // 正文
     $content = "您好:\r\n";
     $content .= "   这里是正文\r\n ";
     // excel路径
     $filePath = dirname(__FILE__) . '/excel';
     $sdate = date('Y-m-d');
     $PreName = 'CleverCode_' . $sdate;
     // 文件名
     $fileName = $filePath . '/' . $PreName . '.xls';
     // 压缩excel文件
     $cmd = "cd {$filePath} && zip {$PreName}.zip {$PreName}.xls";
     exec($cmd, $out, $status);
     $fileList = $filePath . '/' . $PreName . '.zip';
     // 发送邮件(附件为压缩后的文件)
     $ret = SendMail::send($fromAddress, $toAddress, $subject, $content, $fileList);
     if ($ret != 'OK') {
         return $ret;
     }
     return 'OK';
 }
 /**
  * Registration user
  */
 public function actionRegistration()
 {
     $this->layout = '//layouts/login';
     $model = new RegistrationForm();
     // ajax validator
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'signup-form_id') {
         /* echo UActiveForm::validate($model);
            Yii::app()->end(); */
         $errors = CActiveForm::validate($model);
         echo $errors;
         Yii::app()->end();
     }
     if (Yii::app()->user->id) {
         $this->redirect('/');
     } else {
         $this->redirect('/login');
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             $model->verifyPassword = $model->password;
             if ($model->validate()) {
                 $soucePassword = $model->password;
                 $model->activkey = UsersModule::encrypting(microtime() . $model->password);
                 $model->password = UsersModule::encrypting($model->password);
                 $model->verifyPassword = UsersModule::encrypting($model->verifyPassword);
                 $model->status = Yii::app()->getModule('users')->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
                 if ($model->save()) {
                     Yii::app()->queue->subscribe($model->id, null, "User.{$model->id}");
                     if (Yii::app()->getModule('users')->sendActivationMail) {
                         $activation_url = $this->createAbsoluteUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
                         UsersModule::sendMail($model->email, UsersModule::t("You registered from {site_name}", array('{site_name}' => Yii::app()->name)), UsersModule::t("Please activate you account go to {activation_url}", array('{activation_url}' => $activation_url)));
                     }
                     // wellcome email
                     $subject = Yii::t('email', 'Welcome');
                     $message = Yii::t('email', 'Welcome to <a href="{url}">{catalog}</a>.', array('{url}' => $this->createAbsoluteUrl('/'), '{catalog}' => Yii::app()->name));
                     SendMail::send($model->email, $subject, $message, true);
                     if ((Yii::app()->getModule('users')->loginNotActiv || Yii::app()->getModule('users')->activeAfterRegister && Yii::app()->getModule('users')->sendActivationMail == false) && Yii::app()->getModule('users')->autoLogin) {
                         $identity = new UserIdentity($model->username, $soucePassword);
                         $identity->authenticate();
                         Yii::app()->user->login($identity, 0);
                         $this->redirect(Yii::app()->getModule('users')->returnUrl);
                     } else {
                         if (!Yii::app()->getModule('users')->activeAfterRegister && !Yii::app()->getModule('users')->sendActivationMail) {
                             Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Contact Admin to activate your account."));
                         } elseif (Yii::app()->getModule('users')->activeAfterRegister && Yii::app()->getModule('users')->sendActivationMail == false) {
                             Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Please {{login}}.", array('{{login}}' => CHtml::link(UsersModule::t('Login'), Yii::app()->getModule('users')->loginUrl))));
                         } elseif (Yii::app()->getModule('users')->loginNotActiv) {
                             Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Please check your email or login."));
                         } else {
                             Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Please check your email."));
                         }
                         $this->refresh();
                     }
                 }
             } else {
                 // var_dump($model->errors);die();
             }
         }
         $this->render('/user/registration', array('model' => $model));
     }
 }
Пример #4
0
 public function callAction()
 {
     $data = array_intersect_key($_POST, array_flip(array('phone', 'fio', 'formid')));
     // Validate data
     $validator = new Validator($data);
     $validator->rule('empty', 'formid')->message('Некорректный идентификатор формы');
     $validator->rule('required', 'phone')->message('Поле не заполнено');
     $validator->rule('phone', 'phone')->message('Некорректный номер телефона');
     if ($validator->validate()) {
         if (empty($data['fio'])) {
             $data['fio'] = 'Личный номер';
         }
         unset($data['formid']);
         // Send to subscribers
         $mailers = MSCore::db()->getCol('SELECT mail FROM `' . PRFX . 'mailer` WHERE type = ' . self::TARGET_CALL . ' OR type = 0');
         $data['date'] = date('Y-m-d H:i:s');
         MSCore::db()->insert(PRFX . 'order_call', $data);
         if (is_array($mailers) && !empty($mailers)) {
             // Send email
             $sendMail = new SendMail();
             $sendMail->init();
             $sendMail->setSubject('Обратный звонок на ' . DOMAIN);
             $sendMail->setFrom('noreply@' . DOMAIN, 'Первая кровельная');
             // Prepare body
             $message = template('email/call', array('data' => $data));
             $sendMail->setMessage($message);
             foreach ($mailers as $_email) {
                 $sendMail->setTo($_email);
                 $sendMail->send();
             }
             unset($sendMail);
         }
         $content = template('ajax/success/call');
         $this->addData(array('content' => $content));
     } else {
         $errors = $validator->errors();
         foreach ($errors as $_name => $_error) {
             if (is_array($_error)) {
                 $errors[$_name] = reset($_error);
             }
         }
         $this->errorAction(1001, 'Некорректно заполненные поля', array('errors' => $errors));
     }
 }
Пример #5
0
 * @license     Mediasite LLC
 * @link        http://www.mediasite.ru/
 */
require_once dirname(__FILE__) . '/../console.php';
// Достать письма
$query = new MSTable('{mails}');
$query->setFields(['*']);
$mails = $query->getItems();
// Отправить письма
foreach ($mails as $mailItem) {
    $mail = new SendMail();
    $mail->init();
    $mail->setEncoding("utf8");
    $mail->setEncType("base64");
    $mail->setSubject($mailItem['subject']);
    $mail->setMessage($mailItem['text']);
    $mail->setFrom($mailItem['from'], "apstroy");
    $mail->setFiles([$mailItem['files']]);
    $emails = MSCore::db()->getCol('SELECT `mail` FROM `' . PRFX . 'mailer`');
    foreach ($emails as $email) {
        $mail->setTo($email);
        $mail->send();
    }
}
// Удалить письма и файлы
foreach ($mails as $mailItem) {
    MSCore::db()->execute("DELETE FROM `" . PRFX . 'mails' . "` WHERE `id` = " . $mailItem['id']);
    if (file_exists($mailItem['files'])) {
        unlink($mailItem['files']);
    }
}
Пример #6
0
/* Set the actual message, both HTML and TXT
-------------------------------------------------------------------*/
// Load the HTML template
//$template_file = fopen ( 'mail_template.html' , 'r' );
/*$template = '';
	while (!feof ($template_file)) {
		$template .= fgets ($template_file);
	}
	fclose ($template_file); */
$msg = <<<MSG
this is text test mail in php
MSG;
/*$mailer->reparseMail ( $template , array (
		'name'=>'Jason Vertucio',
		'email'=>'*****@*****.**',
		'phone'=>'(212) 555-1212',
		'message'=>$msg
	));*/
//$mailer->setHtmlMessage($template);
$mailer->setTextMessage(nl2br($msg));
// Note that this will actually show you all the HTML
// tags and is NOT a good way of performing the task
echo "msg:::" . var_dump($msg);
/* Actually send the message!
-------------------------------------------------------------------*/
// Uncomment the following line and enter your information to send an email using SMTP.
// $mailer->setSMTP( server , port (25 or 26) , username , password );
$result = $mailer->send();
?>

Пример #7
0
    protected function sendMessageByEmail($message, $subscription)
    {

        $user = User::model()->findByPk($subscription->subscriber_id);
        $userMain = User::model()->findByPk($message->sender_id);
        $text = $message->notification->email;
        $sub = $message->notification->email_subject;
        
        if(!empty($message->subject_pk)){
            $subject = User::model()->findByPk($message->subject_pk);
            $subject_url =  CHtml::link($subject->username, Yii::app()->createAbsoluteUrl('/users/user/view', array('url' => $subject->username)));
            $text = str_replace('{user}', $subject_url, $text);
        }

      if(!$sub)
        $sub = 'Notification from '.Yii::app()->name;
      $send = SendMail::send($user->email,$sub,$text,true);
      if($send === true){
        return true;
      } else {
        Yii::log(Yii::t('NfyModule.app', 'Failed to send notification {message_id} to user {user_id} via email.', array('{message_id}' => $message->id, '{user_id}' => $subscription->subscriber_id)), 'error', 'nfy');
        return false;
      }

    }
Пример #8
0
 public function actionFeedbackUpdate()
 {
     $model = new FormFeedbackUpdate();
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'form-feedback-update') {
         $model->attributes = Yii::app()->request->getPost('FormFeedbackUpdate');
         $errors = CActiveForm::validate($model);
         if ($errors !== '[]') {
             echo $errors;
         } else {
             if ($model->validate()) {
                 $org = Orgs::model()->findByPk($model->org);
                 $url = Yii::app()->createAbsoluteUrl('/catalog/catalog/item', array('city' => $org->city->url, 'id' => $org->id, 'itemurl' => $org->url));
                 $subject = 'Обновление: ' . $org->title;
                 $content = 'Обновить данные <a href="' . $url . '">' . $org->title . '</a><br><br>';
                 $content .= $model->content . '<br><br>';
                 if (!Yii::app()->user->isGuest) {
                     $content .= 'Пользователь: ' . Yii::app()->user->username;
                 } else {
                     $content .= "Пользователь: Аноним";
                 }
                 // $mailto = '*****@*****.**';
                 $mailto = '*****@*****.**';
                 $send = SendMail::send($mailto, $subject, $content, true);
                 if (!isset($send->ErrorInfo) && !empty($send->ErrorInfo)) {
                     VarDumper::dump($send->ErrorInfo);
                     die;
                     // Ctrl + X    Delete line
                 }
                 if ($send) {
                     $message = 'Ваше сообщение успешно отправлено.';
                     if (Yii::app()->request->isAjaxRequest) {
                         echo CJSON::encode(array('flag' => true, 'message' => $message));
                     } else {
                         Yii::app()->user->setFlash('success', $message);
                         $this->refresh();
                     }
                 } else {
                     $message = 'Ошибка отправки сообщения.';
                     // $message .= $send->ErrorInfo;
                     if (Yii::app()->request->isAjaxRequest) {
                         echo CJSON::encode(array('flag' => false, 'message' => $message));
                     } else {
                         Yii::app()->user->setFlash('error', $message);
                         $this->refresh();
                     }
                 }
                 Yii::app()->end();
             }
         }
     }
     Yii::app()->end();
 }
 /**
  * Recovery password
  */
 public function actionRecovery()
 {
     //   $this->layout = '//layouts/login';
     $model = new UserLogin();
     $modelRecovery = new UserRecoveryForm();
     $this->performAjaxValidation($modelRecovery, 'form-reminder');
     if (Yii::app()->user->id) {
         $this->redirect('/');
     } else {
         $email = Yii::app()->request->getParam('email');
         $activkey = Yii::app()->request->getParam('activkey');
         $email = !empty($email) ? $email : '';
         $activkey = !empty($activkey) ? $activkey : '';
         if ($email && $activkey) {
             $form2 = new UserChangePassword();
             $this->performAjaxValidation($form2, 'change_password');
             $find = User::model()->notsafe()->findByAttributes(array('email' => $email));
             if (isset($find) && $find->activkey == $activkey) {
                 if (isset($_POST['UserChangePassword'])) {
                     $form2->attributes = $_POST['UserChangePassword'];
                     if ($form2->validate()) {
                         $find->password = Yii::app()->getModule('users')->encrypting($form2->password);
                         $find->activkey = Yii::app()->getModule('users')->encrypting(microtime() . $form2->password);
                         if ($find->status == 0) {
                             $find->status = 1;
                         }
                         $find->save();
                         $message = Yii::t('site', 'New password is saved.');
                         if (Yii::app()->request->isAjaxRequest) {
                             echo CJSON::encode(array('flag' => true, 'message' => $message));
                             Yii::app()->end();
                         } else {
                             Yii::app()->user->setFlash('recoveryMessage', $message);
                             $this->redirect(Yii::app()->getModule('users')->recoveryUrl);
                         }
                     }
                 }
                 $this->render('changepasswordnew', array('model' => $form2));
             } else {
                 Yii::app()->user->setFlash('recoveryMessage', UsersModule::t("Incorrect recovery link."));
                 // $this->redirect(Yii::app()->getModule('users')->recoveryUrl);
                 $this->redirect('/');
             }
         } else {
             if (isset($_POST['UserRecoveryForm'])) {
                 $modelRecovery->attributes = $_POST['UserRecoveryForm'];
                 if ($modelRecovery->validate()) {
                     $user = User::model()->notsafe()->findbyPk($modelRecovery->user_id);
                     $activation_url = $this->createAbsoluteUrl(implode(Yii::app()->getModule('users')->recoveryUrl) . '?activkey=' . $user->activkey . '&email=' . $user->email);
                     $subject = UsersModule::t("Request for password recovery in {site_name}", array('{site_name}' => Yii::app()->name));
                     $message = UsersModule::t("You have requested the password recovery for access to {site_name}.<br> To get the password and to set the new one follow the link: {activation_url}", array('{site_name}' => Yii::app()->name, '{activation_url}' => $activation_url));
                     // UsersModule::sendMail($user->email, $subject, $message);
                     SendMail::send($user->email, $subject, $message, true);
                     $message = Yii::t('site', "Please check your e-mail.<br> Instruction was sent to your e-mail address.");
                     if (Yii::app()->request->isAjaxRequest) {
                         echo CJSON::encode(array('flag' => true, 'message' => $message));
                         Yii::app()->end();
                     } else {
                         Yii::app()->user->setFlash('recoveryMessage', $message);
                         $this->refresh();
                     }
                 }
             }
             $this->render('recovery', array('model' => $model, 'modelRecovery' => $modelRecovery));
         }
     }
 }
Пример #10
0
 /**
  * @brief 发送验证邮箱邮件
  */
 public function send_check_mail()
 {
     $email = IReq::get('email');
     if (IValidate::email($email) == false) {
         IError::show(403, '邮件格式错误');
     }
     $userDB = new IModel('user');
     $userRow = $userDB->getObj('email = "' . $email . '"');
     $code = base64_encode($userRow['email'] . "|" . $userRow['id']);
     $url = IUrl::getHost() . IUrl::creatUrl("/simple/check_mail/code/{$code}");
     $content = mailTemplate::checkMail(array("{url}" => $url));
     //发送邮件
     $smtp = new SendMail();
     $result = $smtp->send($email, "用户注册邮箱验证", $content);
     if ($result === false) {
         IError::show(403, "发信失败,请重试!或者联系管理员查看邮件服务是否开启");
     }
     $message = "您的邮箱验证邮件已发送到{$email}!请到您的邮箱中去激活";
     $this->redirect('/site/success?message=' . urlencode($message) . '&email=' . $email);
 }
Пример #11
0
 function do_find_password()
 {
     $username = IReq::get('username');
     if ($username === null || !Util::is_username($username)) {
         die("请输入正确的用户名");
     }
     $useremail = IReq::get("useremail");
     if ($useremail === null || !IValidate::email($useremail)) {
         die("请输入正确的邮箱地址");
     }
     $captcha = IReq::get("captcha");
     if ($captcha != ISafe::get('Captcha')) {
         die('验证码输入不正确');
     }
     $tb_user = new IModel("user");
     $username = IFilter::act($username);
     $useremail = IFilter::act($useremail);
     $user = $tb_user->query("username='******' AND email='{$useremail}'");
     if (!$user) {
         die("没有这个用户");
     }
     $user = end($user);
     $hash = IHash::md5(microtime(true) . mt_rand());
     $tb_find_password = new IModel("find_password");
     //重新生成
     $tb_find_password->setData(array('hash' => $hash, 'user_id' => $user['id'], 'addtime' => time()));
     $sendMail = true;
     if ($tb_find_password->query("`hash` = '{$hash}'") || $tb_find_password->add()) {
         $smtp = new SendMail();
         $url = IUrl::creatUrl("/simple/restore_password/hash/{$hash}");
         $url = IUrl::getHost() . $url;
         $content = "请你点击下面这个链接修改密码:<a href='{$url}'>{$url}</a>。<br />如果不能点击,请您把它复制到地址栏中打开。<br />本链接在3天后将自动失效。";
         $re = $smtp->send($user['email'], "您的密码找回", $content);
         if ($re === false) {
             die("发信失败");
         }
         die("success");
     }
     die("找回密码失败");
 }
Пример #12
0
 public function orderAction()
 {
     if (isset($_POST)) {
         $data = [];
         try {
             if (!isset($_POST['name'])) {
                 throw new Exception('name');
             }
             $data['name'] = htmlspecialchars($_POST['name']);
             if (!isset($_POST['phone'])) {
                 throw new Exception('phone');
             }
             $data['phone'] = htmlspecialchars($_POST['phone']);
             if (!isset($_POST['comment'])) {
                 throw new Exception('comment');
             }
             $data['comment'] = htmlspecialchars($_POST['comment']);
             if (!isset($_POST['path'])) {
                 throw new Exception('path');
             }
             $data['path'] = htmlspecialchars($_POST['path']);
             if (!isset($_POST['address'])) {
                 throw new Exception('honeyPot');
             }
             $honeyPot = htmlspecialchars($_POST['address']);
             $data['honeyPot'] = $honeyPot;
             // Проверка на бота
             if ($honeyPot != '') {
                 $this->errorAction(1001, 'Custom system error', ['honeyPot' => 'honeyPot']);
             }
             // Валидация
             $v = new Validator(['name' => $data['name'], 'phone' => $data['phone'], 'comment' => $data['comment']]);
             $v->rule('required', 'comment')->message('comment!');
             $v->rule('required', 'name')->message('name!');
             $v->rule('regex', 'name', '/^([a-zа-я\\s\\-]+)$/iu')->message('name!!');
             $v->rule('required', 'phone')->message('phone!');
             $v->rule('phone', 'phone')->message('phone!!');
             if ($v->validate()) {
                 if (!empty($data['path'])) {
                     $query = new MSTable('{www}');
                     $query->setFields(['title_page']);
                     $query->setFilter('path_id = ' . $data['path']);
                     $data['path'] = $query->getItem();
                     $data['path'] = $data['path']['title_page'];
                 }
                 // Проверяем есть ли файл в наличии
                 $type = 'modal';
                 if (isset($_SESSION['uploaded'][$type]['directory'])) {
                     $path = $_SESSION['uploaded'][$type]['directory'];
                     unset($_SESSION['uploaded'][$type]['directory']);
                 }
                 $title = "Заявка с сайта " . DOMAIN;
                 $msg = template('email/order', $data);
                 if (isset($path)) {
                     $files = str_replace('\\', '/', $path);
                     $from = "noreply@" . DOMAIN;
                     // Помещаем в базу
                     MSCore::db()->insert(PRFX . 'mails', ['subject' => $title, 'files' => $files, 'text' => $msg, 'from' => $from]);
                     $msg = template('email/order', $data + ['files' => $files]);
                 } else {
                     $mail = new SendMail();
                     $mail->init();
                     $mail->setEncoding("utf8");
                     $mail->setEncType("base64");
                     $mail->setSubject($title);
                     $mail->setMessage($msg);
                     $mail->setFrom("noreply@" . DOMAIN, "apstroy");
                     $emails = MSCore::db()->getCol('SELECT `mail` FROM `' . PRFX . 'mailer`');
                     foreach ($emails as $email) {
                         $mail->setTo($email);
                         $mail->send();
                     }
                 }
                 $sql = "\n                        INSERT INTO mp_list(`title`,`text`)\n                        VALUES('" . $title . "','" . $msg . "');\n                    ";
                 MSCore::db()->execute($sql);
                 $this->addData(['succes' => 'Ok']);
                 $this->successAction();
             } else {
                 $errors = $v->errors();
                 foreach ($errors as $_name => $_error) {
                     if (is_array($_error)) {
                         $errors[$_name] = reset($_error);
                     }
                 }
                 $this->errorAction(1001, 'Custom system error', ['data' => $data, 'error' => $errors]);
             }
         } catch (Exception $exception) {
             $error = $exception->getMessage();
             $this->errorAction(1001, 'Custom system error', ['error' => $error, 'postArgument' => 'noPostArgument']);
         }
     }
 }
Пример #13
0
 protected function sendMailAction()
 {
     $mailBody;
     // メール本文作成
     foreach ($this->formObject as $key => $value) {
         $this->smarty->assign($key, $value->getValueString());
     }
     $this->smarty->clear_cache($this->mailTemplate);
     $mailBody = $this->smarty->fetch($this->mailTemplate);
     // メール送信
     $mailObj = new SendMail($this->fromMailAddress, $this->toMailAddress, $this->mailTitle, $mailBody);
     $mailObj->send();
 }
Пример #14
0
 /**
  * Displays the contact page
  */
 public function actionContact()
 {
     $this->pageTitle = Yii::app()->name . ' - ' . Yii::t('site', 'Contact');
     $model = new ContactForm();
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'contact-form') {
         $model->attributes = Yii::app()->request->getPost('ContactForm');
         $errors = CActiveForm::validate($model);
         if ($errors !== '[]') {
             echo $errors;
         } else {
             if ($model->validate()) {
                 $subject = 'Анетика. Сообщение с формы обратной связи.';
                 $content = null;
                 $content .= 'Имя: ' . $model->name . "\r\n";
                 $content .= 'E-mail: ' . $model->email . "\r\n" . 'Сообщение: ' . "\r\n" . $model->body;
                 $mailto = '*****@*****.**';
                 // $mailto = '*****@*****.**';
                 $send = SendMail::send($mailto, $subject, $content, false);
                 if (!isset($send->ErrorInfo) && !empty($send->ErrorInfo)) {
                     VarDumper::dump($send->ErrorInfo);
                     die;
                     // Ctrl + X    Delete line
                 }
                 if ($send) {
                     $message = Yii::t('site', 'Your message has been successfully sent');
                     if (Yii::app()->request->isAjaxRequest) {
                         echo CJSON::encode(array('flag' => true, 'message' => $message));
                     } else {
                         Yii::app()->user->setFlash('success', $message);
                         $this->refresh();
                     }
                 } else {
                     $message = Yii::t('site', 'Error sending message.');
                     // $message .= $send->ErrorInfo;
                     if (Yii::app()->request->isAjaxRequest) {
                         echo CJSON::encode(array('flag' => false, 'message' => $message));
                     } else {
                         Yii::app()->user->setFlash('error', $message);
                         $this->refresh();
                     }
                 }
             }
         }
         Yii::app()->end();
     }
     $this->render('contact', array('model' => $model));
 }
Пример #15
0
<?php

header("Content-Type: text/html; charset=windows-1251");
include "sendmail.php";
$mail = new SendMail('Пользователь задал вопрос');
$name = $_POST['name'];
$mess = $_POST['message'];
$email = $_POST['email'];
$message = '<html><head><title>Вопрос от пользователя</title></head>
    <body>
        <p>' . date("d/m") . ' в ' . date("H:i") . ' получен вопрос от пользователя <strong>' . iconv('UTF-8', 'Windows-1251', $name) . '</strong>:
		<p>' . iconv('UTF-8', 'Windows-1251', $mess) . '<p>E-mail для обратной связи:<em>' . $email . '</em></p>
    </body>
</html>';
$send = $mail->send($message);
if ($send !== true) {
    echo 'Не удалось отправить сообщение, пожалуйста свяжитесь с нами по электронной почте: <br />' . $send->message;
} else {
    echo 'Сообщение было отправлен! В самое ближайшше время мы ответим на Ваш вопрос!';
}
Пример #16
0
 /**
  * 忘记密码
  * @author Terry<*****@*****.**>
  * @date 2013-08-11
  */
 public function getPassword()
 {
     if (IS_POST) {
         $ary_post = $this->_post();
         if ($_SESSION['av'] == md5($ary_post['verify'])) {
             //                $mailConf = D('Config')->getCfgByModule('MAILSET');
             //                $ary_mailconf = json_decode($mailConf['MAILSET'], true);
             $smtp = new SendMail();
             $ary_member = D($this->name)->where(array("m_name" => $ary_post['username'], 'm_email' => $ary_post['email']))->find();
             if (!empty($ary_member) && is_array($ary_member)) {
                 $title = '找回密码';
                 $tpl_data = array();
                 $tpl_data['username'] = $ary_member['m_name'];
                 //生成随机码
                 $time = time();
                 $activation = md5($ary_member['m_reg_time'] . substr($ary_member['m_passwd'], 10) . $time);
                 $url_args = array('username' => $ary_member['m_name'], 'activation' => $activation, 't' => $time);
                 $tpl_data['reset_url'] = U('User/resetPwd', $url_args, '', '', true);
                 $content = D("MessageTpl")->getMailInfo("findpwd", $tpl_data);
                 if ($smtp->send($ary_member['m_email'], $title, $content)) {
                     $this->success("找回密码邮件已经发送到您的邮箱,请查看邮件继续操作");
                 } else {
                     $this->error("邮件发送失败,请联系管理员");
                 }
             } else {
                 $this->error("用户不存在,请重试...");
             }
         } else {
             $this->error("验证码有误……");
         }
     } else {
         $this->display();
     }
 }
Пример #17
0
 /**
  * @brief 发送信件
  */
 function registry_message_send()
 {
     $smtp = new SendMail();
     $error = $smtp->getError();
     $list = array();
     $tb = new IModel("email_registry");
     $ids = IReq::get('ids');
     $ids_sql = "";
     if ($ids) {
         $ids = explode(",", $ids);
         $ids = IFilter::act($ids, 'int');
         $ids = implode(",", $ids);
         $ids_sql = "id IN ({$ids})";
     }
     set_time_limit(0);
     $title = IFilter::act(IReq::get('title'));
     $content = IReq::get("content");
     $start = 0;
     $query = new IQuery("email_registry");
     $query->fields = "email";
     $query->order = "id DESC";
     $query->where = $ids_sql;
     do {
         $query->limit = "{$start},50";
         $list = $query->find();
         if (count($list) == 0) {
             break;
         }
         $start += 1000;
         $to = array_pop($list);
         $to = $to['email'];
         $bcc = array();
         foreach ($list as $value) {
             $bcc[] = $value['email'];
         }
         $bcc = implode(";", $bcc);
         $smtp->send($to, $title, $content, $bcc);
     } while (count($list) >= 50);
     echo "success";
 }
Пример #18
0
<?php

$mailer = new SendMail();
$mailer->add_recipient("", "*****@*****.**");
//$mailer->add_recipient("Support","*****@*****.**");
$mailer->message("Toolbox", "Toolbox_Report this is a test mail from toolbox");
$mailer->send();
Пример #19
0
require_once JApplicationHelper::getPath('admin_html');
require_once JPATH_COMPONENT . DS . 'admin.wnewsletter.class.php';
require_once JPATH_COMPONENT . DS . 'controller.php';
JTable::addIncludePath(JPATH_COMPONENT . DS . 'tables');
$id = JRequest::getVar('id', '', 'get', 'int', 0);
$cid = JRequest::getVar('cid', '', 'post', 'array', array(0));
switch ($task) {
    //save status and ordering
    case "confirmed":
        confirmed($cid, 1, $option);
        break;
    case "unconfirmed":
        confirmed($cid, 0, $option);
        break;
    case 'send':
        SendMail::send();
        break;
        // process product by controller
    // process product by controller
    default:
        $controller = new wNewsLetterController(array('default_task' => 'showNewsLetter'));
        $controller->execute(JRequest::getVar('task'));
        $controller->redirect();
}
function confirmed($cid, $confirmed, $option)
{
    global $mainframe;
    $database =& JFactory::getDBO();
    if (count($cid) < 1) {
        $action = $confirmed ? 'confirmed' : 'unconfirmed';
        JError::raiseWarning('ERROR_CODE', JText::_('Select an Item to ' . $action));
Пример #20
0
 /**
  * 测试邮件发送
  * @author Terry<*****@*****.**>
  * @date 2013-08-31
  */
 public function testSendMail()
 {
     $ary_get = $this->_get();
     $smtp = new SendMail($ary_get);
     if ($error = $smtp->getError()) {
         $this->error($error);
     } else {
         if (!empty($ary_get['test_address'])) {
             $title = '邮件测试--HuiCMS内容管理系统';
             $content = '这是一封测试邮件';
             if ($smtp->send($ary_get['test_address'], $title, $content)) {
                 $this->success("恭喜你!测试通过");
             } else {
                 $this->error("测试失败,请确认您的邮箱已经开启的smtp服务并且配置信息均填写正确");
             }
         } else {
             $this->error("测试邮件地址不能为空");
         }
     }
 }
Пример #21
0
 public function callAction()
 {
     if (isset($_POST)) {
         $data = [];
         try {
             if (!isset($_POST['name'])) {
                 throw new Exception('name');
             }
             $data['name'] = htmlspecialchars($_POST['name']);
             if (!isset($_POST['phone'])) {
                 throw new Exception('phone');
             }
             $data['phone'] = htmlspecialchars($_POST['phone']);
             if (!isset($_POST['email'])) {
                 throw new Exception('email');
             }
             $data['email'] = htmlspecialchars($_POST['email']);
             if (!isset($_POST['comment'])) {
                 throw new Exception('comment');
             }
             $data['comment'] = htmlspecialchars($_POST['comment']);
             if (!isset($_POST['address'])) {
                 throw new Exception('honeyPot');
             }
             $honeyPot = htmlspecialchars($_POST['address']);
             $data['honeyPot'] = $honeyPot;
             // Проверка на бота
             if ($honeyPot != '') {
                 $this->errorAction(1001, 'Custom system error', ['honeyPot' => 'honeyPot']);
             }
             // Валидация
             $v = new Validator(['name' => $data['name'], 'phone' => $data['phone'], 'email' => $data['email'], 'comment' => $data['comment']]);
             $v->rule('required', 'comment')->message('comment!');
             $v->rule('required', 'name')->message('name!');
             $v->rule('regex', 'name', '/^([a-zа-я\\s\\-]+)$/iu')->message('name!!');
             $v->rule('required', 'phone')->message('phone!');
             $v->rule('phone', 'phone')->message('phone!!');
             $v->rule('required', 'email')->message('email!');
             $v->rule('email', 'email')->message('email!!');
             if ($v->validate()) {
                 $msg = template('email/call', $data);
                 $title = "Вопрос с сайта " . DOMAIN;
                 $mail = new SendMail();
                 $mail->init();
                 $mail->setEncoding("utf8");
                 $mail->setEncType("base64");
                 $mail->setSubject($title);
                 $mail->setMessage($msg);
                 $mail->setFrom("noreply@" . DOMAIN, "eko");
                 $emails = MSCore::db()->getCol('SELECT `mail` FROM `' . PRFX . 'mailer`');
                 foreach ($emails as $email) {
                     $mail->setTo($email);
                     $mail->send();
                 }
                 $sql = "\n                        INSERT INTO mp_list(`title`,`text`)\n                        VALUES('" . $title . "','" . $msg . "');\n                    ";
                 MSCore::db()->execute($sql);
                 $this->addData(['succes' => 'Ok']);
                 $this->successAction();
             } else {
                 $errors = $v->errors();
                 foreach ($errors as $_name => $_error) {
                     if (is_array($_error)) {
                         $errors[$_name] = reset($_error);
                     }
                 }
                 $this->errorAction(1001, 'Custom system error', ['data' => $data, 'error' => $errors]);
             }
         } catch (Exception $exception) {
             $error = $exception->getMessage();
             $this->errorAction(1001, 'Custom system error', ['error' => $error, 'postArgument' => 'noPostArgument']);
         }
     }
 }