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); }
/** * 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)); } }
/** * Looks up user supplied email address / alias and sends a mail * * @param $email email address or username */ function sendMail($in) { $in = trim($in); if (is_email($in)) { $user_id = UserFinder::byEmail($in); } else { $user_id = UserFinder::byUsername($in); } $error = ErrorHandler::getInstance(); if (!$user_id) { $error->add('Invalid email address or username'); return false; } $email = UserSetting::getEmail($user_id); if (!$email) { throw new \Exception('entered email not found'); } $code = Token::generate($user_id, 'activation_code'); $pattern = array('/@USERNAME@/', '/@IP@/', '/@URL@/', '/@EXPIRETIME@/'); $user = User::get($user_id); $page = XmlDocumentHandler::getInstance(); $url = $page->getUrl() . 'u/reset_pwd/' . $code; $replacement = array($user->getName(), client_ip(), $url, shortTimePeriod($this->expire_time_email)); $msg = preg_replace($pattern, $replacement, $this->password_msg); //d($msg); $mail = SendMail::getInstance(); $mail->addRecipient($email); $mail->setSubject('Forgot password'); $mail->send($msg); return true; }
/** * getInstanceメソッド * * このクラスのオブジェクトを生成する。 * 既に生成されていたら、前回と同じものを返す。 * * @return object $instance */ public static function getInstance() { if (!self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
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'; }
public function complate() { /** * 完了画面用 * */ //メール送信処理 include_once 'SendMail.php'; $mail = new SendMail(); //画像用のプラグイン発動 include_once 'Image.php'; $file = new Image(); $mail->mailto = $mail->data['email']['content']; $mail->mailadmin = '*****@*****.**'; $mail->subject = '【杉本梁江堂】お問い合わせ受付のお知らせ'; $mail->subadmin = '【杉本梁江堂 お問い合わせ】フォームメール投稿内容'; $mail->mailfrom = '*****@*****.**'; $mail->content = dirname(__FILE__) . '/Email/text/purchase.txt'; $mail->attachments = array('file1' => $_POST['file1'], 'file2' => $_POST['file2'], 'file3' => $_POST['file3']); $mail->content_admin = dirname(__FILE__) . '/Email/text/purchase-admin.txt'; $mail->Send(); }
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)); } }
/** * @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); }
/** * 忘记密码 * @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(); } }
$deletUser = new DeleteUser(); $deletUser->borrarUser(); return Redirect::to('lista'); break; case 'addUserGroup': $addUserGroup = new AddUserToGroup(); $addUserGroup->agregarUsuario(); return Redirect::to('lista'); break; case 'prueba': $prueba = new Revisados(); $prueba->codigos(); break; case 'revisados': $rev = new Revisados(); $rev->enviar(); return Redirect::to('admin'); break; case 'excel': $excel = new SendMail(); $excel->create_excel(); break; case 'cargar_vistas': DB::table('aperturas')->insert(array('campania' => Input::get('camp'), 'cantidad' => Input::get('vistas'), 'fecha' => Input::get('fecha'))); return Redirect::to('cargar'); break; default: return View::make($page); break; } }));
<?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();
//10 minutes define("WARN_LIMIT", 50); //warn limit is 50 $mysql_server_name = MonitorConf::$dbhost; $mysql_username = MonitorConf::$dbuser; $mysql_password = MonitorConf::$dbpass; $mysql_database = MonitorConf::$dbname; $now = time(); $start_time = date('Y-m-d H:i', $now - INTERVAL * 60); $end_time = date('Y-m-d H:i', $now); $query_db_date = date('Ym', $now); $conn = mysql_connect($mysql_server_name, $mysql_username, $mysql_password); if (!$conn) { die('Could not connect: ' . mysql_error()); } $sendmail = new SendMail(); $strsql = "select count(*) as number from weibotc.tc_topnews_" . $query_db_date . " where UNIX_TIMESTAMP(time) >UNIX_TIMESTAMP(NOW()) - 60 *" . INTERVAL . " and time < DATE_FORMAT(now(),'%Y-%m-%d %H:%i');"; //echo $strsql; $result = mysql_query($strsql, $conn); /* $row_num = mysqli_num_rows($result); if ($row_num != 1) { die("Fetch error!"); } */ while ($row = Mysql_fetch_row($result)) { if ($row[0] <= WARN_LIMIT) { echo "sendmail"; $sendmail->sendmail_func($start_time, $end_time, $row[0]); } else {
<?php include "smtp.class.php"; $Email = new SendMail(); $Email->Servidor = "localhost"; $Email->Autenticado = TRUE; $Email->Usuario = "*****@*****.**"; //Digite o Usuário de e-mail você@seudominio $Email->Senha = "r4v3ng4"; //Digite a Senha do email você@seudominio $Email->EmailDe = $_POST['origem']; //Digite o e-mail do remetente $Email->EmailPara = "*****@*****.**"; //Digite o Destino $Email->Assunto = $_POST['assunto']; // Digite o Assunto $Email->Corpo = $_POST['mensagem']; //Digite o Corpo /* * Caso precise anexar arquivos no email * utilize: * $Email->Anexar("/caminho/do/arquivo/1"); * $Email->Anexar("/caminho/do/arquivo/2"); * ... * Não se esqueça que é necessário fazer o * upload do cliente para o servidor primeiro * */ //Envia o email if ($Email->Enviar()) { echo "Seu email foi enviado corretamente";
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; } }
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));
/** * @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"; }
namespace cd; set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../core/'); require_once 'core.php'; require_once 'SendMail.php'; // external MTA example /* $sendmail = SendMail::getInstance(); $sendmail->useMta(true); $sendmail->addRecipient('*****@*****.**'); $sendmail->setSubject('subj åöl'); $sendmail->send('helo world'); */ // Gmail example $mail = SendMail::getInstance(); //$mail->setDebug(true); $mail->setServer('smtp.gmail.com'); $mail->setUsername('gmail-username'); $mail->setPassword('password'); $mail->setPort(587); // TLS/STARTTLS $mail->setFrom('*****@*****.**', 'martin testar'); $mail->setReplyTo('*****@*****.**'); $mail->addRecipients(array('*****@*****.**', '*****@*****.**')); if (count($mail->getRecipients()) != 2) { echo "FAIL 1\n"; } $mail->setSubject('message åäö subject'); //$mail->attachFile('/home/ml/Desktop/bilder/167968_193900863954437_140855739258950_730662_4411055_n.jpg'); $msg = 'abc åäö 123';
include_once $_SERVER['DOCUMENT_ROOT'] . "/eventconfig.php"; include_once CLASSFOLDER . "/sendmail/Testsendmail.php"; /*$sendmail = new sendmailclass(); $from_address = "*****@*****.**"; $from_name = "Prabhakar"; $subject = "Test"; $html_message = "this is test mail"; $toname = "prabhakarindia2006"; $tomailid = "prabhakarindia2006@gmail"; $sendmail->sendHtmlEMail($from_address, $from_name, $toname, $tomailid, $subject, $html_message, $html_message); */ /* Instantiate Object -------------------------------------------------------------------*/ //$mailer = new SendMail ( MSG_TXT ); $mailer = new SendMail(MSG_HTML + MSG_TXT); $mailer->setSMTP('smtp.gmail.com', '465', '*****@*****.**', 'prabhaprofit121085'); /* Set Basics, like sender, recipient (receiver), a CC, and the subject -------------------------------------------------------------------*/ $mailer->setSender('Prabhakar', '*****@*****.**'); $mailer->setReceiver('senthil', '*****@*****.**'); //$mailer->addCC('you','*****@*****.**'); $mailer->subject = 'This is a test message.'; /* 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); }
/** * mailToメソッド * * メール送信実行 * * @param string $mailAddress 送信するメアド * @param array $$mailElements 送信する要素 * [from_address]:メール送信元アドレス * [from_name] :メール送信元名(任意) * [return_path] :リターンアドレス(任意) * [subject] :メールタイトル * [text_body] :メール本文(テキスト) * [html_body] :メール本文(HTML)(任意) * @return 送信成功:True 送信失敗:False */ public function mailTo($mailElements, $sec = 0, $imageData = null, $imageType = null) { $SendMailOBJ = SendMail::getInstance(); return $SendMailOBJ->mailTo($mailElements, $sec, $imageData, $imageType); }
* * Отправитель писем, работает по CRON * * @author Pereskokov Yurii * @copyright 2016 Pereskokov Yurii * @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) {
/** * sendAffiliateDataメソッド * * アフィリエイトデータを送信。 * * @param interger $userId ユーザーID * @param array $aryAffiliateValue QUERY_STRINGの配列 * @param interger $sendType 送信種別 * @param interger $isSuccess 成功タグか失敗タグか * @return boolean * */ public function sendAffiliateData($userId, $aryAffiliateValue, $sendType, $isSuccess = true) { if (!$aryAffiliateValue or !$aryAffiliateValue["advcd"]) { return FALSE; } $UserOBJ = User::getInstance(); $userData = $UserOBJ->getUserData($userId); if (!$userData) { return FALSE; } // 過去に登録済みか if ($userData["pc_address"] and $UserOBJ->chkUserDataFromPcMailAddressDuplication($userData["pc_address"], $userId)) { return FALSE; } else { if ($userData["mb_serial_number"] and $UserOBJ->chkUserDataFromMbSerialNumberDuplication($userData["mb_serial_number"], $userId)) { return FALSE; } } // アフィリエイトデータの取得 $affiliateData = $this->getAffiliateDataFromAdvcd($aryAffiliateValue["advcd"], $sendType); // 成功時のみ発行の場合は失敗ならfalseを返す if (!$affiliateData or !$affiliateData["path"] or $affiliateData["is_success_only"] and !$isSuccess) { return FALSE; } $url = $affiliateData["path"]; /* if (!$aryAffiliateValue["from_first_payment"]) { // 成功パラメータを設定する if ($isSuccess AND $affiliateData["success_parameter"]) { $url .= (strpos($url, "?") ? "&" . $affiliateData["success_parameter"] : "?" . $affiliateData["success_parameter"]); // 失敗パラメータを設定する } else if ($affiliateData["failure_parameter"]) { $url .= (strpos($url, "?") ? "&" . $affiliateData["failure_parameter"] : "?" . $affiliateData["failure_parameter"]); } } else { // 初入金パラメータを設定する if ($affiliateData["first_payment_parameter"]) { $url .= (strpos($url, "?") ? "&" . $affiliateData["first_payment_parameter"] : "?" . $affiliateData["first_payment_parameter"]); $setUserParam["affiliate_tag_first_payment_status"] = 1; } else { return FALSE; } } */ if ($aryAffiliateValue["payment"]) { // 入金パラメータを設定する if ($affiliateData["payment_parameter"]) { $url .= strpos($url, "?") ? "&" . $affiliateData["payment_parameter"] : "?" . $affiliateData["payment_parameter"]; } else { return FALSE; } } else { if ($aryAffiliateValue["from_first_payment"]) { // 初入金パラメータを設定する if ($affiliateData["first_payment_parameter"]) { $url .= strpos($url, "?") ? "&" . $affiliateData["first_payment_parameter"] : "?" . $affiliateData["first_payment_parameter"]; $setUserParam["affiliate_tag_first_payment_status"] = 1; } else { return FALSE; } } else { // 成功パラメータを設定する if ($isSuccess and $affiliateData["success_parameter"]) { $url .= strpos($url, "?") ? "&" . $affiliateData["success_parameter"] : "?" . $affiliateData["success_parameter"]; // 失敗パラメータを設定する } else { if ($affiliateData["failure_parameter"]) { $url .= strpos($url, "?") ? "&" . $affiliateData["failure_parameter"] : "?" . $affiliateData["failure_parameter"]; } } } } // メールアドレス変数を作成する $userData["mail_address"] = $userData["pc_address"] ? $userData["pc_address"] : $userData["mb_address"]; // アドレス(「.」を「_」に変換)変数を作成する $userData["dot_address"] = str_replace(".", "_", rawurlencode($userData["mail_address"])); $returnValue = explode(",", $affiliateData["return_variable"]); $changeValue = explode(",", $affiliateData["change_variable"]); // 情報を変換する foreach ($returnValue as $key => $val) { if (!$affiliateData["connect_type"] == self::CONNECT_TYPE_IMG) { if ($changeValue[$key] == "payment") { $getData[] = $val . "=" . $aryAffiliateValue["payment"]; } else { $getData[] = $val . "=" . ($aryAffiliateValue[$changeValue[$key]] ? $aryAffiliateValue[$changeValue[$key]] : $userData[$changeValue[$key]]); } } else { if ($aryAffiliateValue[$changeValue[$key]]) { $affiliateValue = $aryAffiliateValue[$changeValue[$key]]; } elseif ($userData[$changeValue[$key]]) { $affiliateValue = $userData[$changeValue[$key]]; } else { $affiliateValue = $changeValue[$key]; } $getData[] = $val . "=" . $affiliateValue; } } $url = $url . (strpos($url, "?") ? "&" . implode("&", $getData) : "?" . implode("&", $getData)); // タグのデコードをする $url = htmlspecialchars_decode($url, ENT_QUOTES); $httpParam = array("maxredirects" => 1, "timeout" => 30); if ($affiliateData["connect_type"] == self::CONNECT_TYPE_SOCKET) { if (!$aryAffiliateValue["payment"]) { // 「初入金時」は更新カラム変更 if (!$aryAffiliateValue["from_first_payment"]) { $setUserParam["affiliate_tag_url"] = htmlspecialchars($url, ENT_QUOTES); } else { $setUserParam["affiliate_tag_first_payment_url"] = htmlspecialchars($url, ENT_QUOTES); } } else { //入金タグを配列に格納 $insertArray["affiliate_tag_url"] = htmlspecialchars($url, ENT_QUOTES); } $setUserParam["update_datetime"] = date("Y-m-d H:i:s"); $userWhere[] = "id = " . $userId; try { // ソケット通信 $ComHttpOBJ = new ComHttp($url, $httpParam); $result = $ComHttpOBJ->request("GET"); if ($result->isSuccessful()) { if (!$aryAffiliateValue["payment"]) { // 「初入金時」は更新カラム変更 if (!$aryAffiliateValue["from_first_payment"]) { $setUserParam["affiliate_tag_status"] = 1; } else { $setUserParam["affiliate_tag_first_payment_status"] = 1; } } } else { $SendMailOBJ = SendMail::getInstance(); $mailElements["subject"] = "アフィリエイトソケット通信エラー"; $mailElements["text_body"] = "ユーザーID:" . $userId . "\nurl:" . $url . "\n\n" . $result->getMessage(); // システムにエラーメール $SendMailOBJ->debugMailTo($mailElements); // 運営にエラーメール $SendMailOBJ->operationMailTo($mailElements); } } catch (Exception $e) { $SendMailOBJ = SendMail::getInstance(); $mailElements["subject"] = "アフィリエイトソケット通信エラー"; $mailElements["text_body"] = "ユーザーID:" . $userId . "\nurl:" . $url . "\n\n" . $e->getMessage(); // システムにエラーメール $SendMailOBJ->debugMailTo($mailElements); // 運営にエラーメール $SendMailOBJ->operationMailTo($mailElements); } if ($userId) { if ($aryAffiliateValue["payment"]) { $insertArray["user_id"] = $userId; $insertArray["media_cd"] = $aryAffiliateValue["advcd"]; $insertArray["create_datetime"] = date("Y-m-d H:i:s"); $insertArray["update_datetime"] = date("Y-m-d H:i:s"); //入金タグ関連のデータをpayment_parameter_logにインサート if (!$this->insertPaymentAffiliateTagLog($insertArray)) { $this->_errorMsg[] = "データ登録できませんでした。"; return FALSE; } } else { if (!$UserOBJ->updateUserData($setUserParam, $userWhere)) { $this->_errorMsg[] = "データ更新できませんでした。"; return FALSE; } } } return TRUE; } else { if ($affiliateData["connect_type"] == self::CONNECT_TYPE_IMG) { // アドレス部分をURLエンコードした値に置換 $address = $userData["dot_address"]; $encodeAddress = urlencode($address); $url = str_replace($address, $encodeAddress, $url); $this->_imgTag = "<img src=\"" . $url . "\" width=\"1\" height=\"1\">"; // DB格納する前にURLデコード //$tag = urldecode($this->_imgTag); // 「初入金時」は更新カラム変更 if (!$aryAffiliateValue["from_first_payment"]) { $setUserParam["affiliate_tag_url"] = htmlspecialchars($this->_imgTag, ENT_QUOTES); $setUserParam["affiliate_tag_status"] = 1; } else { $setUserParam["affiliate_tag_first_payment_url"] = htmlspecialchars($this->_imgTag, ENT_QUOTES); $setUserParam["affiliate_tag_first_payment_status"] = 1; } $setUserParam["update_datetime"] = date("Y-m-d H:i:s"); $userWhere[] = "id = " . $userId; if ($userId) { if (!$UserOBJ->updateUserData($setUserParam, $userWhere)) { $this->_errorMsg[] = "データ更新できませんでした。"; return FALSE; } } return TRUE; } } }
/** * SMTP接続を開始する。 * * @param * * @return boolean */ public function openSmtpConnect() { // 未接続なら接続処理 if (!$this->smtp_conn) { $mailServerIpAry = array(); // IPが空ならデフォルトセット if (!$this->_smtpMailServerIp) { // デフォルト(通常) $this->setSendMailServerIp($this->_configOBJ->common_config->smtp_mail_server_ip->sendMagic); } // ホストとポートに分ける $mailServerIpAry = explode(":", $this->_smtpMailServerIp); // host $host = $mailServerIpAry[0]; // port $port = $mailServerIpAry[1]; // 接続先をセット $this->setSmtpHost($host, (int) $port); // 接続 try { // 接続出来なければ、リトライ(指定秒間隔) for ($cnt = 0; $cnt < $this->_retrySmtpConnCnt; $cnt++) { // 接続確立 if ($this->_openSmtpConn()) { break; } // 10秒インターバル sleep($this->_retrySmtpInterval); } // それもダメならさよなら。 if (!$this->getSmtpConnect()) { return false; } // 接続後、最初に必要なSMTPコマンドをここでやっちゃおう!! if (!$this->_sendSmtpCommand("helo " . $this->smtp_host, array(220, 250, 354))) { return false; } } catch (Zend_Exception $e) { // デバッグメール $SendMailOBJ = SendMail::getInstance(); $debugMail = ""; $debugMail["subject"] = "SMTP接続エラー"; $debugMail["text_body"][] = "file:" . __FILE__; $debugMail["text_body"][] = "line:" . __LINE__; $debugMail["text_body"][] = "err:" . $e->getMessage(); $debugMail["text_body"][] = "server_ip:" . $this->_smtpMailServerIp; $debugMail["text_body"] = implode("\n", $debugMail["text_body"]); // システムにエラーメール $SendMailOBJ->debugMailTo($debugMail); } } return true; }
} } // メール送信 // メール文言取得 $AutoMailOBJ = AutoMail::getInstance(); // 別途%変換用にセット $convAry = $OrderingOBJ->makeOrderConvertArray($orderingData); // キーコンバート用データの取得 $cvdKeyconvData = $SettlementCvdOBJ->getCvdKeyconvData(); $convAry["-%cvs_name-"] = $cvName; $convAry["-%pay_limit-"] = date("Y/m/d", strtotime($cvdKeyconvData["payLimit"])); $convAry["-%shno-"] = $cvdKeyconvData["shnoMailString"]; // リメールデータの取得 $mailAddress = $comUserData["mb_address"] ? $comUserData["mb_address"] : $comUserData["pc_address"]; $mailElementsData = $AutoMailOBJ->getAutoMailData("ordering", $cvdRemailKey, $mailAddress); $mailElements = $AutoMailOBJ->convertMailElements($mailElementsData["elements"], $comUserData["user_id"], $convAry); // メール送信 if (!$AutoMailOBJ->mailTo($mailElements, "", $mailElementsData["image_data"], $mailElementsData["image_type"])) { $SendMailOBJ = SendMail::getInstance(); $mailElements["subject"] = "コンビニダイレクト決済予約メール送信エラー"; $mailElements["text_body"] = "注文ID:" . $orderingData["id"] . "\n金額:" . $orderingData["pay_total"] . "\nユーザーにメール送信できませんでした。"; // システムにエラーメール $SendMailOBJ->debugMailTo($mailElements); // 運営にエラーメール $SendMailOBJ->operationMailTo($mailElements); $errSessOBJ->errMsg[] = "メール送信できませんでした。<br>お手数ですが、お問い合わせよりご連絡ください。"; header("Location: ./?action_SettleCvd=1&" . $URLparam . ($comURLparam ? "&" . $comURLparam : "") . "&" . $sessId); exit; } header("Location: ./?action_SettleCvdEnd=1&" . $URLparam . ($comURLparam ? "&" . $comURLparam : "") . "&" . $sessId . "&name1=" . $param["name1"] . "&name2=" . $param["name2"] . "&telno=" . $param["telno"]); exit;
/** * @param $dataSourceName * @param $bypassAuth * @return mixed */ public function createInDB($bypassAuth) { $currentDataSource = $this->dbSettings->getDataSourceTargetArray(); try { $className = get_class($this->userExpanded); // if ($this->userExpanded !== null && method_exists($this->userExpanded, "doBeforeNewToDB")) { // $this->logger->setDebugMessage("The method 'doBeforeNewToDB' of the class '{$className}' is calling.", 2); // $this->userExpanded->doBeforeNewToDB($dataSourceName); // } if ($this->userExpanded !== null && method_exists($this->userExpanded, "doBeforeCreateToDB")) { $this->logger->setDebugMessage("The method 'doBeforeCreateToDB' of the class '{$className}' is calling.", 2); $this->userExpanded->doBeforeCreateToDB(); } if ($this->dbClass !== null) { if (isset($currentDataSource['send-mail']['new']) || isset($currentDataSource['send-mail']['create']) || $this->dbSettings->notifyServer) { $this->dbClass->requireUpdatedRecord(true); } $result = $this->dbClass->createInDB($bypassAuth); } // if ($this->userExpanded !== null && method_exists($this->userExpanded, "doAfterNewToDB")) { // $this->logger->setDebugMessage("The method 'doAfterNewToDB' of the class '{$className}' is calling.", 2); // $result = $this->userExpanded->doAfterNewToDB($dataSourceName, $this->dbClass->updatedRecord()); // } if ($this->userExpanded !== null && method_exists($this->userExpanded, "doAfterCreateToDB")) { $this->logger->setDebugMessage("The method 'doAfterCreateToDB' of the class '{$className}' is calling.", 2); $result = $this->userExpanded->doAfterCreateToDB($this->dbClass->updatedRecord()); } if ($this->dbSettings->notifyServer && $this->clientPusherAvailable) { try { $this->dbSettings->notifyServer->created($_POST['notifyid'], $this->dbClass->queriedEntity(), $this->dbClass->queriedPrimaryKeys(), $this->dbClass->updatedRecord()); } catch (Exception $ex) { if ($ex->getMessage() == '_im_no_pusher_exception') { $this->logger->setErrorMessage("The 'Pusher.php' isn't installed on any valid directory."); } else { throw $ex; } } } if (isset($currentDataSource['send-mail']['new']) || isset($currentDataSource['send-mail']['create'])) { $this->logger->setDebugMessage("Try to send an email."); $mailSender = new SendMail(); if (isset($currentDataSource['send-mail']['new'])) { $dataSource = $currentDataSource['send-mail']['new']; } else { if (isset($currentDataSource['send-mail']['create'])) { $dataSource = $currentDataSource['send-mail']['create']; } } $mailResult = $mailSender->processing($dataSource, $this->dbClass->updatedRecord(), $this->dbSettings->getSmtpConfiguration()); if ($mailResult !== true) { $this->logger->setErrorMessage("Mail sending error: {$mailResult}"); } } } catch (Exception $e) { $this->logger->setErrorMessage("Exception: {$e->getMessage()}"); return false; } return $result; }
<?php include 'header/header.php'; include 'class/sendmail.php'; //$user = $_SESSION["username"]; $send = new SendMail(); $errors = ['u_name' => null, 'u_email' => null, 'u_subject' => null, 'u_message' => null, 'form' => null]; $conne = ''; $form = true; $target_dir = "articleimage/"; $target_file = null; $imageFileType = null; if (!empty($_POST)) { if (empty($_POST['u_name'])) { $errors['u_name'] = "Please Enter Your Name"; $form = false; } if (empty($_POST['u_email'])) { $errors['user_email'] = "Please Enter Your email"; $form = false; } elseif (!filter_var($_POST['u_email'], FILTER_VALIDATE_EMAIL)) { $errors['user_email'] = "Enter Valid Email"; $form = false; } if (empty($_POST['u_subject'])) { $errors['u_subject'] = "Please Enter Subject"; $form = false; } if (empty($_POST['u_message'])) { $errors['u_message'] = "Please Enter Message"; $form = false;
<?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 'Сообщение было отправлен! В самое ближайшше время мы ответим на Ваш вопрос!'; }
/** * 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)); } } }
/** * sendToBitcashメソッド * * bitcashサーバーと通信をする * ├カード認証 * └決済実行 * * @param array $orderingData 注文データ * @param string $card_number カード番号(ひらがな16文字) * * @return array $result ビットキャッシュからの戻り値 * */ function sendToBitcash($orderingData, $cardNumber) { if (!$orderingData or !$cardNumber) { return FALSE; } $ComXmlRpcClientOBJ = new ComXmlRpcClient(self::BITCASH_URL); try { $ComXmlRpcClientOBJ->setSkipSystemLookup(true); $proxy = $ComXmlRpcClientOBJ->getProxy("Settlement"); /* ■■■■■■■■■ * バリデートロジック * ■■■■■■■■■ * ビットキャッシュ側にカード、金額データを送信して * チェックを行う。 */ $validateParam["SHOP_ID"] = self::BITCASH_SHOP_ID; $validateParam["SHOP_PASSWD"] = self::BITCASH_SHOP_PASS; $validateParam["CARD_NUMBER"] = $cardNumber; $validateParam["RATING"] = self::BITCASH_RATING; $validateParam["PRICE"] = $orderingData["pay_total"]; $validateParam["ORDER_ID"] = $orderingData["id"]; $validateParam = Zend_XmlRpc_Value::getXmlRpcValue($validateParam, Zend_XmlRpc_Value::XMLRPC_TYPE_STRUCT); $validateResult = $proxy->validate_card($validateParam); if (!$validateResult) { $this->_errorMsg = "validate_card_false_result"; return false; } else { if ($validateResult["faultCode"]) { $this->_errorMsg = "validate_card_fault_code"; return false; } } /* 返り値の取得 * * * 1.ERRORの場合 例)カード情報が違う * Array * ( [STATUS] => FAIL * [ERROR] => Array( [0] => 354:bad_card_number ) * [LOG_ID] => 43634282 //バリデーション時の入出力ID * ) * * 2.OKの場合 * Array * ([BALANCE] => 100000 //バリデーション実行正常終了時のクレジット数(引き落とし前のクレジット数) * [BCS_ID] => 1581403990 //バリデーション正常終了時に発行されるセッション番号(決済実行時に使用) * [ERROR] => Array() * [STATUS] => OK * [LOG_ID] => 43634465 //バリデーション時の入出力ID * ) */ // 有効ではない if ($validateResult["ERROR"]) { $this->_errorMsg = $validateResult["ERROR"][0]; return false; } // 有効ではない if ("OK" != $validateResult["STATUS"]) { $this->_errorMsg = "validate_card_bad_status"; return false; } /* ■■■■■■ * 決済ロジック * ■■■■■■ * STATUSがOKで帰ってきたらまたbitcashにデータの送信。決済を行う。 */ $param["SHOP_ID"] = self::BITCASH_SHOP_ID; $param["SHOP_PASSWD"] = self::BITCASH_SHOP_PASS; $param["CARD_NUMBER"] = $cardNumber; $param["BCS_ID"] = $validateResult["BCS_ID"]; $param["PRICE"] = $orderingData["pay_total"]; $param["ORDER_ID"] = $orderingData["id"]; $param = Zend_XmlRpc_Value::getXmlRpcValue($param, Zend_XmlRpc_Value::XMLRPC_TYPE_STRUCT); $result = $proxy->do_settlement($param); if (!$result) { $this->_errorMsg = "do_settlement_false_result"; return false; } else { if ($result["faultCode"]) { $this->_errorMsg = "do_settlement_fault_code"; return false; } } /* 返り値の取得 * * 1.ERRORの場合 例)BCS_ID(バリデート時に生成されるID)がない場合 * Array * ( [STATUS] => FAIL * [ERROR] => Array([0] => 304:no_bcs_id) * [LOG_ID] => 43641701 //決済時の入出力ID * ) * * 2.OKの場合 * Array * ( [SALES_ID] => 28293032 //決済実行正常終了時の販売ID * [BALANCE] => 99900 //決済実行正常終了時の残りクレジット数。 * [ERROR] => Array() * [STATUS] => OK * [LOG_ID] => 43641640 //決済時の入出力ID * ) */ // 有効ではない if ($result["ERROR"]) { $this->_errorMsg = $result["ERROR"][0]; return false; } // 有効ではない if ("OK" != $result["STATUS"]) { $this->_errorMsg = "do_settlement_bad_status"; return false; } return $result; } catch (Zend_XmlRpc_Client_HttpException $e) { // HTTP通信エラー $SendMailOBJ = SendMail::getInstance(); $mailElements["subject"] = "ビットキャッシュHTTP通信エラー"; $mailElements["text_body"] = "注文ID:" . $orderingData["id"] . "\nカード番号:" . $cardNumber . "\n金額:" . $orderingData["pay_total"] . "\n" . $e; $SendMailOBJ->debugMailTo($mailElements); return FALSE; } catch (Zend_XmlRpc_Client_FaultException $e) { // RPC実行エラー $SendMailOBJ = SendMail::getInstance(); $mailElements["subject"] = "ビットキャッシュRPC実行エラー"; $mailElements["text_body"] = "注文ID:" . $orderingData["id"] . "\nカード番号:" . $cardNumber . "\n金額:" . $orderingData["pay_total"] . "\n" . $e; $SendMailOBJ->debugMailTo($mailElements); return FALSE; } }
/** * 测试邮件发送 * @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("测试邮件地址不能为空"); } } }
/** * convertMailElementsメソッド * * メールタイトル、文言、HTML等の%変換処理を実施 * * @param array $contents メールコンテンツ * @param integer $userId 送信相手のUserテーブルID * @param array $convertAry %変換用配列(個別処理用) * @return array 変換済みメール要素配列 */ public function convertMailElements($elements, $userId = "", $convertAry = "") { $SendMailOBJ = SendMail::getInstance(); return $SendMailOBJ->convertMailElements($elements, $userId, $convertAry); }