public function actionDecline($id) { if (!($model = Invite::model()->findByPk($id)) || !in_array($model->status, [Invite::INVITE_CREATE, Invite::INVITE_ACCEPT])) { throw new CHttpException(404); } if ($model->status == Invite::INVITE_CREATE) { $mail = new YiiMailer(); $mail->setView('invite/decline'); $mail->setFrom(isset(Yii::app()->params->YiiMailer->Username) ? Yii::app()->params->YiiMailer->Username : Yii::app()->params->adminEmail, 'Система управления учебным расписанием'); $mail->setTo($model->email); $mail->setSubject('Заявка на создание'); $mail->send(); if (!$mail->send()) { Yii::app()->user->setFlash('error', 'Ошибка при отправке письма'); $this->redirect(['index']); } } $model->status = Invite::INVITE_DECLINE; if ($model->save()) { Yii::app()->user->setFlash('success', 'Заявка успешно отклонена'); } else { Yii::app()->user->setFlash('error', 'Ошибка при смене статуса'); } $this->redirect(['index']); }
public static function sendEmail($subject, $to_email, $body, $from_email, $from_name) { $mail = new YiiMailer(); $mail->setView('confirm'); $mail->setData(array('data' => $body)); $mail->setFrom($from_email, $from_name); $mail->setSubject($subject); $mail->setTo($to_email); if ($mail->send()) { return TRUE; } return FALSE; }
public function processSurveys(array $surveys) { foreach ($surveys as $survey) { if ($survey->surveyInfo == null) { $info = new SurveyInfo(); $info->surveyId = $survey->sid; $info->surveyType = $survey->location; $survey->surveyInfo = $info; } if ($survey->surveyInfo->isActive == null) { $survey->surveyInfo->isActive = $survey->isActive(); $survey->surveyInfo->save(); } else { if ($survey->surveyInfo->isActive && $survey->surveyInfo->isActive != $survey->isActive()) { $attachedFiles = AttachedFile::model()->findAllByAttributes(array('fileType' => AttachedFile::FILE_TYPE_FULL_ANALYTICS, 'modelId' => $survey->sid, 'modelType' => get_class($survey))); $linksToFiles = array(); $filesToAttachment = array(); foreach ($attachedFiles as $file) { if ($file->attachType == AttachedFile::ATTACH_TYPE_LINK) { $linksToFiles[$file->filePath] = $file->name; } elseif ($file->attachType == AttachedFile::ATTACH_TYPE_FILE) { $filesToAttachment[$file->filePath] = $file->fileName; } } $exportHelper = new ExcelExportSurveyHelper($survey); $res = $exportHelper->export(); if ($res != null) { $excelFilepath = "/tmp/" . md5(time() . "_" . $survey->sid . "_" . $survey->location) . '.xls'; file_put_contents($excelFilepath, $res['content']); $filesToAttachment[$excelFilepath] = 'Массив данных в Excel.xls'; } $mail = new YiiMailer(); $mail->setFrom(Yii::app()->params['adminEmail'], 'Администраток ЛК'); $mail->setTo(Yii::app()->params['adminEmail']); $mail->setSubject('Опрос перешёл в список завершённых.'); $mail->setView('surveyChangeActivity'); $mail->setData(array('survey' => $survey, 'linksToFiles' => $linksToFiles)); $mail->setAttachment($filesToAttachment); echo "[" . date("Y-m-d H:i:s") . "] try to send mail\n"; if (!$mail->send()) { echo "[" . date("Y-m-d H:i:s") . "] fail \n"; print_r($mail->getError()); echo PHP_EOL; } $survey->surveyInfo->isActive = $survey->isActive(); $survey->surveyInfo->save(); } } } }
public static function sendRecoveryPasswordEmail($user, $newPassword) { $mail = new YiiMailer(); $mail->setLayout('mail'); $mail->setView('recoveryPassword'); $mail->setData(array('administrator' => $user, 'new_password' => $newPassword)); $mail->setFrom('*****@*****.**', Yii::app()->params['SITE_NAME']); $mail->setTo($user->username); $mail->setSubject(Yii::t(Yii::app()->params['TRANSLATE_FILE'], 'Instruction to recovery password from ' . Yii::app()->params['SITE_NAME'] . ' system')); if ($mail->send()) { return null; } else { return $mail->getError(); } }
public function sendMailSorry($email) { try { $this->title = "Mail test"; $mail = new YiiMailer(); $mail->setView('sorry'); $mail->setFrom('*****@*****.**', 'John Doe'); $mail->setSubject('Confirm your order'); $mail->setTo($email); $mail->send(); var_dump($mail->getError()); } catch (Exception $e) { var_dump($e->getMessage()); } }
public function afterSave() { if ($this->getScenario() == 'insert') { $user = Users::model()->findByAttributes(['email' => $this->email]); if (!$user) { $group = Group::model()->findByPk($this->group_id); $mail = new YiiMailer(); $mail->setView('invite'); $mail->setData(array('group' => $group, 'hash' => $this->hash)); $mail->setFrom(isset(Yii::app()->params->YiiMailer->Username) ? Yii::app()->params->YiiMailer->Username : Yii::app()->params->adminEmail, 'Система управления учебным расписанием'); $mail->setTo($this->email); $mail->setSubject('Приглашение'); $mail->send(); } } }
public function afterSave() { if ($this->getIsNewRecord()) { $admins = array_map(function ($user) { /** @var Users $user */ return $user->email; }, array_filter(Users::model()->findAll(), function ($user) { /** @var Users $user */ return in_array('admin', array_keys($user->groups)); })); $mail = new YiiMailer(); $mail->setView('invite/new'); $mail->setFrom(isset(Yii::app()->params->YiiMailer->Username) ? Yii::app()->params->YiiMailer->Username : Yii::app()->params->adminEmail, 'Система управления учебным расписанием'); $mail->setTo($admins); $mail->setSubject('Новая заявка'); $mail->send(); } return parent::afterSave(); }
public function send() { $mailer = new YiiMailer(); $maildata = $this->args; if ($this->view) { $mailer->setView($this->view); } $mailer->setData($maildata); $mailer->setFrom($this->from, $this->fromUser); $mailer->setTo($this->to); $mailer->setSubject($this->subject); $mailer->setBody($this->body); $sent = $mailer->send(); if ($sent) { return array('status' => true, 'error' => ''); } else { return array('status' => false, 'error' => $mailer->getError()); } }
public function generarToken() { $a = array('correo' => $this->correo, 'estado' => 1); $validar = Usuario::model()->findByAttributes($a); if ($validar) { $token = md5('tm' . $this->correo . (rand() + time()) . 'TM'); $validar->updateByPk($validar->id, array('llave_activacion' => $token, 'estado' => 3)); $mail = new YiiMailer(); $mail->setView('recuperar-clave'); $mail->setData(array('token' => $token)); $mail->render(); $mail->Subject = 'Recupera tu contraseña de puntos TM'; $mail->AddAddress($this->correo); $mail->From = '*****@*****.**'; $mail->FromName = 'Puntos TM'; $mail->Send(); } return true; }
public function run($args) { //Do some cron processing... $cronResult = "Cron job finished successfuly"; $mail = new YiiMailer(); //use "cron" view from views/mail $mail->setView('cron'); $mail->setData(array('message' => $cronResult, 'name' => get_class($this), 'description' => 'Cron job', 'mailer' => $mail)); //set properties $mail->setFrom('*****@*****.**', 'Console application'); $mail->setSubject($cronResult); $mail->setTo('*****@*****.**'); $mail->setAttachment(Yii::getPathOfAlias('webroot.files') . '/yii-1.1.0-validator-cheatsheet.pdf'); //send if ($mail->send()) { echo 'Mail sent successfuly'; } else { echo 'Error while sending email: ' . $mail->getError(); } echo PHP_EOL; }
public function register() { if (!$this->validate()) { return false; } $user = new User(); $user->setFullName($this->fio); $user->username = $this->email; $user->email = $this->email; $user->password = md5($this->password); $user->passwordConfirm = md5($this->passwordConfirmation); $user->organizationName = $this->organizationName; $user->organizationPhone = $this->organizationPhone; $user->mobilePhone = $this->mobilePhone; $user->isKnownFromSearch = $this->isKnownFromSearch; $user->isKnownFromRecommendation = $this->isKnownFromRecommendation; $user->isKnownFromInetAdvert = $this->isKnownFromInetAdvert; $user->isKnownFromMaps = $this->isKnownFromMaps; $user->isKnownFromOther = $this->isKnownFromOther; if (!$user->save()) { return false; } $auth = Yii::app()->authManager; $defaultRole = $auth->getAuthItem(User::DEFAULT_ROLE); if ($defaultRole) { $auth->assign(User::DEFAULT_ROLE, $user->id); } $mail = new YiiMailer(); $mail->setFrom(Yii::app()->params['noReplyEmail']); $mail->setTo(Yii::app()->params['notificationEmail']); $mail->setSubject('Заявка на регистрацию нового пользователя'); $mail->setView('userRegistration'); $mail->setData(array('user' => $user)); if (!$mail->send()) { error_log('Cannot send email about registered user: ' . $mail->getError()); } return true; }
public function run($args) { //Do some cron processing... $cronResult = "Cron job finished successfuly"; $mail = new YiiMailer(); //use "cron" view from views/mail $mail->setView('cron'); $mail->setData(array('message' => $cronResult, 'name' => get_class($this), 'description' => 'Cron job', 'mailer' => $mail)); //render HTML mail, layout is set from config file or with $mail->setLayout('layoutName') $mail->render(); //set properties as usually with PHPMailer $mail->From = '*****@*****.**'; $mail->FromName = 'Console application'; $mail->Subject = $cronResult; $mail->AddAddress('*****@*****.**'); //send if ($mail->Send()) { $mail->ClearAddresses(); echo 'Mail sent successfully'; } else { echo 'Error while sending email: ' . $mail->ErrorInfo; } echo PHP_EOL; }
public function actionIndex() { $form = new FeedbackForm(); if (Yii::app()->request->isPostRequest) { $params = Yii::app()->request->getParam('FeedbackForm'); $form->setAttributes($params); if ($form->validate()) { $mail = new YiiMailer(); $mail->setView('feedback'); $mail->setData(['form' => $form]); $mail->setFrom($form->email, $form->name); $mail->setReplyTo($form->email); $mail->setTo(Yii::app()->params->adminEmail); $mail->setSubject('Система расписания: ' . $form->subject); if ($mail->send()) { Yii::app()->user->setFlash('success', 'Ваше сообщение отправлено, спасибо!'); $form->unsetAttributes(); } else { Yii::app()->user->setFlash('error', 'Ошибка при отправке'); } } } $this->render('index', ['model' => $form]); }
public function actionEmail() { // get data on variable by channa $variables = array('{fname}' => 'channa', '{lname}' => 'bandara', '{email}' => '*****@*****.**', '{dob}' => '1989-01-01', '{password}' => 'thisiamy password'); //get template using template name by channa $templatedata = self::getemailtemple('User Registration Template'); // function in controller(configuration) //get template data in to variable by channa $description = $templatedata->description; $subject = $templatedata->subject; //send $description $description to VariableReplaceArray by channa $emailbody = $this->VariableReplaceArray($description, $variables); //function in controller(configuration) //send email detail to templte using renderPartial by channa $emailbodydetail = array('emailbodydetail' => $emailbody); //send message detail to template by channa $messageUser = $this->renderPartial('/emailtemplate/template', $emailbodydetail, true); //set up email configuration by channa $mail = new YiiMailer(); //$mail->setLayout('mail'); $mail->setView('template'); $mail->setFrom('*****@*****.**', 'Sarimoon'); $mail->setTo('*****@*****.**'); $mail->setData($emailbodydetail); $mail->setSubject('Testing Email'); if ($mail->send()) { echo 'sent'; } else { echo 'failed'; } /*$name = 'channa'; $email = '*****@*****.**'; $Telephone = '0715977097'; $to = '*****@*****.**'; $subject = $subject; $messageAdmin = "Deal Admin"; self::email($name, $email, $subject, $messageUser); self::email($name, $email, $subject, $messageAdmin, TRUE); $this->render('email');*/ }
private static function constructEmailObject() { // $mail = new YiiMailer(); // $mail->IsSMTP(); // $mail->Host = 'smtp.gmail.com'; // $mail->Port = 587; // $mail->SMTPSecure= 'tls'; // $mail->SMTPAuth = true; // $mail->Username = "******"; // $mail->Password = '******'; // $mail->setView('contact'); // $mail->setLayout('mail'); // $mail->setFrom('*****@*****.**', 'Virtual Job Fair'); // return $mail; $mail = new YiiMailer(); $mail->IsSMTP(); $mail->Host = 'smtp.cs.fiu.edu'; $mail->Port = 25; $mail->SMTPAuth = false; $mail->setView('contact'); $mail->setLayout('mail'); $mail->setFrom('*****@*****.**', 'Virtual Job Fair'); return $mail; }
public function SendMailConfirm() { try { $data = BookService::model()->findByAttributes(array('id' => Yii::app()->session['order_id'])); $this->title = "Mail test"; $mail = new YiiMailer(); $mail->setView('confirm'); $mail->setData(array('data' => $data)); $mail->setFrom('*****@*****.**', 'John Doe'); $mail->setSubject('Confirm your order'); $mail->setTo($data->email); $mail->send(); var_dump($mail->getError()); } catch (Exception $e) { var_dump($e->getMessage()); } }
public function sendEmail($target, $actor, $template) { $url = Yii::app()->createUrl('attendances/beritaacara_approve&id=' . $this->id); if ($_SERVER['HTTP_HOST'] == 'localhost') { $url = 'http://localhost/' . $url; } $mail = new YiiMailer(); $emailbodydetail = array('target' => $target, 'actor' => $actor, 'mutation' => $this, 'url' => $url, 'creator_role' => $this->creator_role, 'creator_name' => $this->creator_employee->fullname); //$mail->setLayout('mail'); if ($email != '') { $mail->setView($template); $mail->setFrom('*****@*****.**', 'hris'); $mail->setTo($target->email); $mail->setData($emailbodydetail); $mail->setSubject('Mutation Rotation'); $mail->send(); } }
public function sendEmail($target, $action) { $actor = getUser()->employee; $mail = new YiiMailer(); $creator = new MastersEmployees(); $attendance_date = $this->date; $attendance_date = strtotime($this->date); $attendance_date = date('j', $attendance_date) . ' ' . getMonthName()[date('n', $attendance_date) - 1] . ' ' . date('Y', $attendance_date); if ($this->created_by == 'employee') { $creator = $this->employee; } else { if ($this->employee->outlet_id == '') { $creator = $this->employee->department->head; } else { $creator = $this->employee->outlet->rm; } } $url = Yii::app()->createUrl('attendances/beritaacara_approve&id=' . $this->id); if ($_SERVER['HTTP_HOST'] == 'localhost') { $url = 'http://localhost/' . $url; } $emailbodydetail = array('target_name' => $target->fullname, 'target_role' => $target->rolename, 'actor_name' => $actor->fullname, 'actor_role' => $actor->rolename, 'creator_name' => $creator->fullname, 'creator_role' => $creator->rolename, 'employee' => $this->employee->fullname, 'location' => $this->location->name, 'action' => $action, 'url' => $url, 'date' => $attendance_date, 'check_in' => $this->check_in, 'check_out' => $this->check_out, 'break_out' => $this->break_out, 'break_in' => $this->break_in); if ($target->email != '') { $mail->setView('template'); $mail->setFrom('*****@*****.**', 'hris'); $mail->setTo($target->email); $mail->setData($emailbodydetail); $mail->setSubject('Berita Acara Request'); $mail->send(); } }
public function actionContactar() { if (isset($_POST['ContactForm']['propuesta'])) { $propuesta = Propuestas::model()->findByAttributes(array('perfiles_id' => $_POST['ContactForm']['propuesta'])); $mContacto = new ContactForm(); $mContacto->attributes = $_POST['ContactForm']; $correo = new YiiMailer(); $correo->setView('contacto'); $correo->setData(array('datos' => $mContacto, 'propuesta' => $propuesta)); $correo->render(); $correo->Subject = $mContacto->asunto; $correo->AddAddress($propuesta->email); $correo->From = $mContacto->email; $correo->FromName = $mContacto->nombre; if ($correo->Send()) { Yii::app()->user->setFlash('success', "El mensaje se ha enviado correctamente."); } else { Yii::app()->user->setFlash('success', "El mensaje no se pudo enviar, por favor intentelo nuevamente."); } } $this->redirect(Yii::app()->request->urlReferrer); }
public function sendMail($template) { $url = Yii::app()->createUrl('attendances/off/view&id=' . $this->id); if ($_SERVER['HTTP_HOST'] == 'localhost') { $url = 'http://localhost/' . $url; } $rm = $this->employee->outlet->rm; $admin = User::model()->findByAttributes(array('role' => 'admin'))->employee; $email = $rm->email; if ($template == 'template_attendance_off_request') { $email = $admin->email; } $mail = new YiiMailer(); $emailbodydetail = array('rm' => $rm, 'admin' => $admin, 'attendance_off' => $this, 'url' => $url, 'employee' => $this->employee); //$mail->setLayout('mail'); if ($email != '') { $mail->setView($template); $mail->setFrom('*****@*****.**', 'hris'); $mail->setTo($email); $mail->setData($emailbodydetail); $mail->setSubject('Kehadiran Off'); $mail->send(); } }
} .site-online{ background-color: green; } .site-offline{ background-color: red; } EOL; Yii::app()->clientScript->registerCss("circle-ness", $newStyle); /*Check class */ $sc = new ServerCheck($data->websiteURL); if ($sc->getServerStatus() === "OFFLINE") { $classname = "site-offline"; //report to sir about the incident $mailer = new YiiMailer(); $mailer->setView('contact'); $mailer->setData(array("websiteURL" => $data->websiteURL, "accountName" => $data->claimAccountName, "description" => "We cant seem to ping these website please double check these website.")); $mailer->setFrom("*****@*****.**"); $mailer->setTo("*****@*****.**"); $mailer->setSubject(" {$data->claimAccountName}- Went Down"); $mailer->send(); } else { } $applicationStatus = $data->application_status == Accounts::OK ? "site-online" : "site-offline"; $dataBaseApplication = $data->database_status == Accounts::OK ? "site-online" : "site-offline"; ?> <div class="view span4"> <h3 class="pull-left" style="display: inline-block;width: 215px;">
public function actionCreate() { // if (!Yii::app()->user->checkAccess('administrator')) { // throw new Http403Exception(); // } $wizard = PublicSurveyRequestWizard::loadWizard(); $surveyRequest = new UserSurveyRequest(); //SurveyRequestHelper::loadSurveyRequestOfCurrentUser(); if (Yii::app()->request->isPostRequest) { $successRequest = true; if ($wizardPost = Yii::app()->request->getPost(get_class($wizard->current()))) { if (!empty($_FILES[get_class($wizard->current())])) { foreach (array_keys($_FILES[get_class($wizard->current())]["name"]) as $fileAttrName) { $wizard->current()->{$fileAttrName} = CUploadedFile::getInstance($wizard->current(), $fileAttrName); } } $wizard->setCurrentData($wizardPost); if (Yii::app()->request->getPost('next')) { if ($successRequest = $wizard->current()->validate()) { $wizard->next(); } } if (Yii::app()->request->getPost('prev')) { $wizard->prev(true); } if (Yii::app()->request->getPost('start')) { if ($successRequest = $wizard->current()->validate()) { $surveyRequest = $this->saveSurveyRequest($wizard, $surveyRequest); $surveyRequest->status = UserSurveyRequest::STATUS_WAITING; $surveyRequest->save(); foreach ($wizard->getFiles() as $name => $file) { $attributes = array('name' => $name, 'fileType' => AttachedFile::FILE_TYPE_SIMPLE_ATTACH, 'attachType' => AttachedFile::ATTACH_TYPE_FILE); AttachedFileHelper::uploadFile(new AttachedFile(), $attributes, get_class($surveyRequest), $surveyRequest->id, $file); } $mail = new YiiMailer(); $mail->setFrom(Yii::app()->params['noReplyEmail']); $mail->setTo(Yii::app()->params['notificationEmail']); $mail->setSubject('Создание нового брифа'); $mail->setView('surveyCreated'); $mail->setData(array('controller' => $this, 'wizard' => $wizard, 'surveyRequest' => $surveyRequest)); $filesToAttachment = array(); foreach ($surveyRequest->files as $file) { $filesToAttachment[$file->filePath] = $file->name; } $mail->setAttachment($filesToAttachment); if (!$mail->send()) { error_log('Cannot send email about survey: ' . $mail->getError()); } Yii::app()->user->setFlash('success', "Запрос на создание проекта успешно отправлен. Специалист BCGroup свяжется с Вами в течение дня."); $wizard = new PublicSurveyRequestWizard(); } } } if (Yii::app()->request->getPost('save')) { $this->saveSurveyRequest($wizard, $surveyRequest); } else { $wizard->temporarySave(); } if ($successRequest) { $this->redirect('create'); } } $this->layout = 'publicMain'; $this->render("create", array('wizard' => $wizard)); }
public function actionDeactivate($id) { $user = $this->loadModel($id); if ($user->id == Yii::app()->user->id) { throw new Http403Exception(); } $user->deactivate(); $mail = new YiiMailer(); $mail->setFrom(Yii::app()->params['noReplyEmail']); $mail->setTo($user->email); $mail->setSubject('Учётная запись заблокирована.'); $mail->setView('userDeactivated'); $mail->setData(array('user' => $user)); if (!$mail->send()) { error_log('Cannot send email about deactivated user: '******'view', 'id' => $user->id)); }
public function reportDatabaseDown() { Yii::import('ext.YiiMailer.YiiMailer'); $mailer = new YiiMailer(); $mailer->setView('contact'); $mailer->setData(array("websiteURL" => $this->websiteURL, "accountName" => $this->claimAccountName, "description" => "Database down.")); $mailer->setFrom("*****@*****.**"); $mailer->setTo(array("*****@*****.**", "*****@*****.**", "*****@*****.**")); $mailer->setSubject(" {$data->claimAccountName}- Database Went Down"); $mailer->send(); }
public function sendEmail($email, $message) { //----- not used ------------ // The message // $message = "Line 1\r\nLine 2\r\nLine 3"; // $message = ' // <html> // <head> // <title></title> // </head> // <body> // '.$message.' // </body> // </html> // '; // To send HTML mail, the Content-type header must be set // $headers = 'MIME-Version: 1.0' . "\r\n"; // $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // In case any of our lines are larger than 70 characters, we should use wordwrap() // $message = wordwrap($message, 70, "\r\n"); // Send // mail($email, 'Mutation or Rotation', $message, $headers); //-------------------------- $emailbodydetail = array('emailbodydetail' => $message); $mail = new YiiMailer(); //$mail->setLayout('mail'); $mail->setView('template'); $mail->setFrom('*****@*****.**', 'hris'); $mail->setTo($email); $mail->setData($emailbodydetail); $mail->setSubject('Mutation Rotation'); $mail->send(); }