Example #1
0
 public function updateRequest($data)
 {
     $req = $this->find($data['id']);
     if ($data['action'] == 'y') {
         $ts3 = new TsAPI();
         // send TS3 create request
         $token = $ts3->createChan($req->cname);
         if ($token) {
             $req->reason = htmlspecialchars($data['msg']);
             $req->status = 1;
             $req->save();
             if ($data['email']) {
                 $email = new Email();
                 $email->sendYes(array('req' => $req, 'token' => $token));
             }
             return 1;
         }
     } elseif ($data['action'] == 'n') {
         $req->reason = htmlspecialchars($data['msg']);
         $req->status = 2;
         $req->save();
         if ($data['email']) {
             $email = new Email();
             $email->sendNo(array('req' => $req));
         }
         return 2;
     }
 }
 public function onBeforeWrite()
 {
     if ($this->owner->BaseClass == "Discussion" && $this->owner->ID == 0) {
         $discussion = Discussion::get()->byID($this->owner->ParentID);
         $discussion_author = $discussion->Author();
         $holder = $discussion->Parent();
         $author = Member::get()->byID($this->owner->AuthorID);
         // Get our default email from address
         if (DiscussionHolder::config()->send_emails_from) {
             $from = DiscussionHolder::config()->send_email_from;
         } else {
             $from = Email::config()->admin_email;
         }
         // Vars for the emails
         $vars = array("Title" => $discussion->Title, "Author" => $author, "Comment" => $this->owner->Comment, 'Link' => Controller::join_links($holder->Link("view"), $discussion->ID, "#comments-holder"));
         // Send email to discussion owner
         if ($discussion_author && $discussion_author->Email && $discussion_author->RecieveCommentEmails && $discussion_author->ID != $this->owner->AuthorID) {
             $subject = _t("Discussions.NewCreatedReplySubject", "{Nickname} replied to your discussion", null, array("Nickname" => $author->Nickname));
             $email = new Email($from, $discussion_author->Email, $subject);
             $email->setTemplate('NewCreatedReplyEmail');
             $email->populateTemplate($vars);
             $email->send();
         }
         // Send to anyone who liked this, if they want notifications
         foreach ($discussion->LikedBy() as $liked) {
             if ($liked->RecieveLikedReplyEmails && $liked->Email && $liked->ID != $author->ID) {
                 $subject = _t("Discussions.NewLikedReplySubject", "{Nickname} replied to your liked discussion", null, array("Nickname" => $author->Nickname));
                 $email = new Email($from, $liked->Email, $subject);
                 $email->setTemplate('NewLikedReplyEmail');
                 $email->populateTemplate($vars);
                 $email->send();
             }
         }
     }
 }
Example #3
0
 /** @test */
 public function it_is_a_correct_object()
 {
     $field = new Email('test', 'Test');
     $this->assertSame('email', $field->getOption('type'));
     $this->assertSame('administr/form::text', $field->getView());
     $this->assertInstanceOf(AbstractType::class, $field);
 }
 /**
  * make sure to return TRUE as response if the message is sent
  * successfully
  * Sends a message from the current user to someone else in the networkd
  * @param Int | String | Member $to -
  * @param String $message - Message you are sending
  * @param String $link - Link to send with message - NOT USED IN EMAIL
  * @param Array - other variables that we include
  * @return Boolean - return TRUE as success
  */
 public static function send_message($to, $message, $link = "", $otherVariables = array())
 {
     //FROM
     if (!empty($otherVariables["From"])) {
         $from = $otherVariables["From"];
     } else {
         $from = Email::getAdminEmail();
     }
     //TO
     if ($to instanceof Member) {
         $to = $to->Email;
     }
     //SUBJECT
     if (!empty($otherVariables["Subject"])) {
         $subject = $otherVariables["Subject"];
     } else {
         $subject = substr($message, 0, 30);
     }
     //BODY
     $body = $message;
     //CC
     if (!empty($otherVariables["CC"])) {
         $cc = $otherVariables["CC"];
     } else {
         $cc = "";
     }
     //BCC
     $bcc = Email::getAdminEmail();
     //SEND EMAIL
     $email = new Email($from, $to, $subject, $body, $bounceHandlerURL = null, $cc, $bcc);
     return $email->send();
 }
 /**
  * Sends a reminder mail to definined member groups.
  */
 public function sendReminderMail()
 {
     // first check if required extension 'associategroups' is installed
     if (!in_array('associategroups', $this->Config->getActiveModules())) {
         $this->log('RscNewsletterReminder: Extension "associategroups" is required!', 'RscNewsletterReminder sendReminderMail()', TL_ERROR);
         return false;
     }
     $this->loadLanguageFile("tl_settings");
     if ($this->timeleadReached()) {
         $objEmail = new \Email();
         $objEmail->logFile = 'RscNewsletterReminderEmail.log';
         $objEmail->from = $GLOBALS['TL_CONFIG']['rscNewsletterReminderEmailSenderAddress'];
         $objEmail->fromName = strlen($GLOBALS['TL_CONFIG']['rscNewsletterReminderEmailSenderName']) > 0 ? $GLOBALS['TL_CONFIG']['rscNewsletterReminderEmailSenderName'] : $GLOBALS['TL_CONFIG']['websiteTitle'];
         $objEmail->subject = $this->replaceEmailInsertTags($GLOBALS['TL_CONFIG']['rscNewsletterReminderEmailSubject']);
         $objEmail->html = $this->replaceEmailInsertTags($GLOBALS['TL_CONFIG']['rscNewsletterReminderEmailContent']);
         $objEmail->text = $this->transformEmailHtmlToText($objEmail->html);
         try {
             $objEmail->sendTo($this->getReceiverEmails());
             $this->log('Monthly sending newsletter reminder finished successfully.', 'RscNewsletterReminder sendReminderMail()', TL_CRON);
             return true;
         } catch (Swift_RfcComplianceException $e) {
             $this->log("Mail could not be send: " . $e->getMessage(), "RscNewsletterReminder sendReminderMail()", TL_ERROR);
             return false;
         }
     }
     return true;
 }
Example #6
0
 public function cadastro($created)
 {
     /**
      * criar uma pessoa
      */
     $modelPessoa = new Pessoa();
     $pessoasId = $modelPessoa->genericInsert(array('tipo_pessoa' => 1, 'created' => $created));
     /**
      * criar uma pessoa fisica
      */
     $ModelPF = new Fisica();
     $ModelPF->genericInsert(array('pessoas_id' => $pessoasId, 'cpf' => '00000000000', 'nome' => $this->getNome()));
     /**
      * criar um contato
      */
     $modelContato = new Contato();
     $contatoId = $modelContato->genericInsert(array('telefone' => Utils::returnNumeric($this->getPhone()), 'tipo' => 1));
     $modelContato->inserirContato($pessoasId, $contatoId);
     /**
      * criar um email
      */
     $modelEmail = new Email();
     $modelEmail->inserirEmailPessoa($pessoasId, $this->getEmail());
     /**
      * criar um usuario
      */
     $modelUsuario = new Usuario();
     $usuarioId = $modelUsuario->genericInsert(array('roles_id' => 1, 'pessoas_id' => $pessoasId, 'status' => 1, 'perfil_teste' => 0, 'created' => $created, 'email' => $this->getEmail(), 'login' => $this->getEmail(), 'senha' => Authentication::password($this->getPhone()), 'chave' => Authentication::uuid(), 'facebook_id' => $this->getFacebookId()));
     $modelCliente = new Cliente();
     $modelCliente->genericInsert(array('pessoas_id' => $pessoasId, 'status' => 1, 'sexo' => 0));
     return $modelCliente->recuperaCliente($this->getNome(), $this->getPhone());
 }
Example #7
0
 public function testEmailDomain()
 {
     $v = new Email();
     $this->assertFalse($v->isValid('test@test.co.m.'));
     $this->assertTrue($v->isValid('*****@*****.**'));
     $this->assertFalse($v->isValid('test@test.co-m'));
 }
Example #8
0
 /**
  * @param string $emailAddress
  * @return mixed if true integer otherwise null
  */
 public static function saveEmailAddress($emailAddress)
 {
     $emailID = null;
     $parseEmail = explode('@', strtolower(trim($emailAddress)));
     if (count($parseEmail) == 2) {
         $domain = Domain::model()->findByAttributes(array('name' => $parseEmail[1]));
         if (!$domain) {
             $domain = new Domain();
             $domain->name = $parseEmail[1];
         }
         if ($domain->save()) {
             $email = new Email();
             $email->username = $parseEmail[0];
             $email->domainID = $domain->ID;
             if ($email->save()) {
                 $emailID = $email->ID;
             } else {
                 if ($domain->isNewRecord) {
                     Domain::model()->deleteByPk($domain->ID);
                 }
             }
         }
     }
     return $emailID;
 }
Example #9
0
 public function sendEmail($emailbody, $time, $value, $options)
 {
     global $user, $session;
     $timeformated = DateTime::createFromFormat("U", (int) $time);
     $timeformated->setTimezone(new DateTimeZone($this->parentProcessModel->timezone));
     $timeformated = $timeformated->format("Y-m-d H:i:s");
     $tag = array("{id}", "{type}", "{time}", "{value}");
     $replace = array($options['sourceid'], $options['sourcetype'], $timeformated, $value);
     $emailbody = str_replace($tag, $replace, $emailbody);
     if ($options['sourcetype'] == "INPUT") {
         $inputdetails = $this->parentProcessModel->input->get_details($options['sourceid']);
         $tag = array("{key}", "{name}", "{node}");
         $replace = array($inputdetails['name'], $inputdetails['description'], $inputdetails['nodeid']);
         $emailbody = str_replace($tag, $replace, $emailbody);
     } else {
         if ($options['sourcetype'] == "VIRTUALFEED") {
             // Not suported for VIRTUAL FEEDS
         }
     }
     $emailto = $user->get_email($session['userid']);
     require_once "Lib/email.php";
     $email = new Email();
     //$email->from(from);
     $email->to($emailto);
     $email->subject('Emoncms event alert');
     $email->body($emailbody);
     $result = $email->send();
     if (!$result['success']) {
         $this->log->error("Email send returned error. message='" . $result['message'] . "'");
     } else {
         $this->log->info("Email sent to {$emailto}");
     }
 }
Example #10
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Usuario();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['Usuario'])) {
         $model->attributes = $_POST['Usuario'];
         $model->estatus_did = 1;
         $model->tipoUsuario_did = 4;
         $model->fechaCreacion_f = date("Y-d-m H:i:s");
         $model->contrasena = md5($model->contrasena);
         if (isset($_POST["noticias"])) {
             $email = new Email();
             $email->nombre = $model->nombre . " " . $model->apPaterno . " " . $model->apMaterno;
             $email->direccion = $model->domCalle . " " . $model->domNo . " " . $model->domColonia;
             $email->telefono = $model->telefono;
             $email->correo = $model->correo;
             $email->estatus_did = 1;
             $email->fecha_f = date("Y-d-m");
             $email->save();
         }
         if ($model->save()) {
             $this->redirect(array('site/index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #11
0
 public function saveData()
 {
     $usuario['id'] = $_POST['id'];
     $usuario['numero_identificacion'] = $usuario['username'] = $_POST['numero_identificacion'];
     $usuario['nombres'] = $_POST['nombres'];
     $usuario['apellidos'] = $_POST['apellidos'];
     $usuario['genero'] = $_POST['genero'];
     $usuario['tipo_usuario_id'] = $_POST['tipo_usuario_id'];
     $usuario['capacidad_especial_id'] = $_POST['capacidad_especial_id'];
     $usuario['password'] = $_POST['password'];
     $usuario['email'] = $_POST['email'];
     $usuario['estado_civil_id'] = $_POST['estado_civil_id'];
     $mail = 0;
     if ($usuario['id'] == 0) {
         $usuario['activo'] = 0;
         $mail = 1;
     }
     $model = new UsuarioModel();
     try {
         $datos = $model->saveUsuario($usuario);
         $_SESSION['message'] = "Datos almacenados correctamente.";
         if ($mail == 1) {
             $token = base64_encode($usuario['numero_identificacion']);
             $email = new Email();
             $email->sendNotificacionRegistro($usuario['nombres'], $usuario['email'], $token);
         }
     } catch (Exception $e) {
         $_SESSION['message'] = $e->getMessage();
     }
     header("Location: index.php");
 }
Example #12
0
 public function sendContactForm($data, $form)
 {
     $email = new Email();
     $email->setFrom('"mSupply Contact Form" <*****@*****.**>')->setTo($this->SiteConfig()->ContactFormEmail)->setSubject('mSupply Message')->setTemplate('ContactFormEmail')->populateTemplate(new ArrayData(array('FullName' => $data['FullName'], 'Phone' => $data['Phone'], 'Email' => $data['Email'], 'Message' => $data['Message'])));
     $email->send();
     return $this->redirectback();
 }
Example #13
0
 function testFilter()
 {
     $email = new Email('*****@*****.**');
     $this->assertFalse($email->getFilter());
     $email = new FilterEmail('*****@*****.**');
     $this->assertTrue($email->getFilter());
 }
Example #14
0
    public static function addMessage($touser, $message)
    {
        $sql = '
			INSERT INTO {{messages}}
			SET 
				fromuser='******'iuser']['id'] . ',
				touser='******',
				message=\'' . $message . '\',
				cdate=NOW()
		';
        DB::exec($sql);
        $sql = 'SELECT CONCAT(fname,\' \',lname) AS name, email FROM {{iusers}} WHERE id=' . $touser . '';
        $row = DB::getRow($sql);
        $toname = $row['name'];
        $email = $row['email'];
        if (trim($toname) == '') {
            $toname = 'Неизвестный';
        }
        $text = '
			Здравствуйте, ' . $toname . '!<br /><br />
			' . $_SESSION['iuser']['name'] . ' написал Вам новое сообщение на сайте <a href="http://' . $_SERVER['HTTP_HOST'] . '">' . $_SERVER['HTTP_HOST'] . '</a>.<br /><br />
		';
        $text = View::getRenderEmpty('email/simple', array('text' => $text, 'title' => 'Новое сообщение'));
        $mail = new Email();
        $mail->To($email);
        $mail->Subject('Новое сообщение от ' . $_SESSION['iuser']['name'] . ' на сайте ' . $_SERVER['HTTP_HOST']);
        $mail->Text($text);
        $mail->Send();
    }
 /**
  * Send mail
  *
  * @param \Cake\Network\Email\Email $email Cake Email
  * @return array
  */
 public function send(Email $email)
 {
     $headers = $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject']);
     $headers = $this->_headersToString($headers);
     $message = implode("\r\n", (array) $email->message());
     return ['headers' => $headers, 'message' => $message];
 }
Example #16
0
    function forgot()
    {
        if ($_POST) {
            DB::escapePost();
            $sql = '
				SELECT * FROM {{users}} WHERE login=\'' . $_POST['login'] . '\'
			';
            $return = DB::getRow($sql);
            if ($return) {
                $pass = Funcs::generate_password(8);
                $sql = '
					UPDATE {{users}}
					SET pass=MD5(\'' . $pass . '\')
					WHERE login=\'' . $_POST['login'] . '\'
				';
                DB::exec($sql);
                $text = '
					Здравствуйте, ' . $return["login"] . '.<br />
					Ваш новый пароль ' . $pass . '.<br />
					Сменить пароль Вы можете в личном кабинете. 
				';
                $mail = new Email();
                $mail->To($return['email']);
                $mail->Subject('Восстановление пароля на сайте www.' . str_replace("www.", "", $_SERVER["HTTP_HOST"]));
                $mail->Text($text);
                $mail->Send();
            }
            $this->redirect('/');
        } else {
            View::$layout = 'empty';
            View::render('site/forgot');
        }
    }
 /**
  * Override the default method to handle the specific things of the download module and
  * update the database after file was successful uploaded.
  * This method has the same parameters as the default.
  * @param  $uploaded_file
  * @param  $name
  * @param  $size
  * @param  $type
  * @param  $error
  * @param  $index
  * @param  $content_range
  * @return stdClass
  */
 protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null)
 {
     global $gPreferences, $gL10n, $gDb, $getId, $gCurrentOrganization, $gCurrentUser;
     $file = parent::handle_file_upload($uploaded_file, $name, $size, $type, $error, $index, $content_range);
     if (!isset($file->error)) {
         try {
             // check filesize against module settings
             if ($file->size > $gPreferences['max_file_upload_size'] * 1024 * 1024) {
                 throw new AdmException('DOW_FILE_TO_LARGE', $gPreferences['max_file_upload_size']);
             }
             // check filename and throw exception if something is wrong
             admStrIsValidFileName($file->name, true);
             // get recordset of current folder from database and throw exception if necessary
             $targetFolder = new TableFolder($gDb);
             $targetFolder->getFolderForDownload($getId);
             // now add new file to database
             $newFile = new TableFile($gDb);
             $newFile->setValue('fil_fol_id', $targetFolder->getValue('fol_id'));
             $newFile->setValue('fil_name', $file->name);
             $newFile->setValue('fil_locked', $targetFolder->getValue('fol_locked'));
             $newFile->setValue('fil_counter', '0');
             $newFile->save();
             // Benachrichtigungs-Email für neue Einträge
             $message = $gL10n->get('DOW_EMAIL_NOTIFICATION_MESSAGE', $gCurrentOrganization->getValue('org_longname'), $file->name, $gCurrentUser->getValue('FIRST_NAME') . ' ' . $gCurrentUser->getValue('LAST_NAME'), date($gPreferences['system_date'], time()));
             $notification = new Email();
             $notification->adminNotfication($gL10n->get('DOW_EMAIL_NOTIFICATION_TITLE'), $message, $gCurrentUser->getValue('FIRST_NAME') . ' ' . $gCurrentUser->getValue('LAST_NAME'), $gCurrentUser->getValue('EMAIL'));
         } catch (AdmException $e) {
             $file->error = $e->getText();
             unlink($this->options['upload_dir'] . $file->name);
             return $file;
         }
     }
     return $file;
 }
Example #18
0
/**
 * Sends a report of the parsing and social update.
 * @param $to [string] e-mail address to send the report to
 * @param $errors [array] list of errors
 * @param $notices [array] list of notices
 * @todo Make template based (plain text and/or HTML using Mailer::setHtml()).
 * @todo This function should probably be in the SocialUpdate class, as well as the error/notice handling.
 */
function sendReport($to, &$errors, &$notices)
{
    if (!$to) {
        return;
    }
    $errorCount = count($errors);
    $from = Config::$siteName . " <no-reply@" . $_SERVER['SERVER_NAME'] . ">";
    $subject = $errorCount ? "Update error" : "Update successful";
    if ($errorCount) {
        $msg = "Your update was not processed because of the following error(s):\n\n";
        foreach ($errors as $error) {
            $msg .= "- {$error}\n\n";
        }
    } else {
        if (count($notices)) {
            $msg = "Your update was successful:\n\n";
            foreach ($notices as $notice) {
                $msg .= "- {$notice}\n\n";
            }
        } else {
            $msg = "Your update was successful.";
        }
    }
    $email = new Email($from, $to, $subject);
    $email->setPlain($msg);
    $email->send();
}
Example #19
0
 public function SendNewsletterForm($data, $form)
 {
     $email = new Email();
     $email->setFrom('"mSupply Newsletter Form" <*****@*****.**>')->setTo($this->SiteConfig()->NewsletterFormEmail)->setSubject('mSupply Newsletter Request')->setTemplate('NewsletterSignUpEmail')->populateTemplate(new ArrayData(array('Email' => $data['Email'])));
     $email->send();
     return $this->redirectback();
 }
 public static function createEmail($id = '', $override = array())
 {
     global $timedate;
     $time = mt_rand();
     $name = 'SugarEmail';
     $email = new Email();
     $email->name = $name . $time;
     $email->type = 'out';
     $email->status = 'sent';
     $email->date_sent = $timedate->to_display_date_time(gmdate("Y-m-d H:i:s", gmmktime() - 3600 * 24 * 2));
     // Two days ago
     if (!empty($id)) {
         $email->new_with_id = true;
         $email->id = $id;
     }
     foreach ($override as $key => $value) {
         $email->{$key} = $value;
     }
     $email->save();
     if (!empty($override['parent_id']) && !empty($override['parent_type'])) {
         self::createEmailsBeansRelationship($email->id, $override['parent_type'], $override['parent_id']);
     }
     self::$_createdEmails[] = $email;
     return $email;
 }
 public function process()
 {
     $config = SiteConfig::current_site_config();
     $datetime = $this->getDatetime();
     $emails = $this->emails;
     if (!count($emails)) {
         $this->isComplete = true;
         return;
     }
     $email = new Email();
     $email->setSubject(sprintf(_t('EventManagement.EVENTREMINDERSUBJECT', 'Event Reminder For %s (%s)'), $datetime->EventTitle(), $config->Title));
     $email->setTemplate('EventReminderEmail');
     $email->populateTemplate(array('SiteConfig' => $config, 'Datetime' => $datetime));
     foreach ($emails as $addr => $name) {
         $_email = clone $email;
         $_email->setTo($addr);
         $_email->populateTemplate(array('Name' => $name));
         $_email->send();
         unset($emails[$addr]);
         $this->emails = $emails;
         ++$this->currentStep;
     }
     if (!count($emails)) {
         $this->isComplete = true;
     }
 }
 /**
  * Send a notification directly to a single user
  *
  * @param SystemNotification $notification
  * @param string $email
  * @param array $data
  */
 public function sendToUser($notification, $context, $user, $data)
 {
     $subject = $notification->format($notification->Title, $context, $user, $data);
     if (Config::inst()->get('SystemNotification', 'html_notifications')) {
         $message = $notification->format($notification->NotificationContent(), $context, $user, $data);
     } else {
         $message = $notification->format(nl2br($notification->NotificationContent()), $context, $user, $data);
     }
     if ($template = $notification->getTemplate()) {
         $templateData = $notification->getTemplateData($context, $user, $data);
         $templateData->setField('Body', $message);
         try {
             $body = $templateData->renderWith($template);
         } catch (Exception $e) {
             $body = $message;
         }
     } else {
         $body = $message;
     }
     $from = $this->config()->get('send_notifications_from');
     $to = $user->Email;
     if (!$to && method_exists($user, 'getEmailAddress')) {
         $to = $user->getEmailAddress();
     }
     // log
     $message = "Sending {$subject} to {$to}";
     SS_Log::log($message, SS_Log::NOTICE);
     // send
     $email = new Email($from, $to, $subject);
     $email->setBody($body);
     $this->extend('onBeforeSendToUser', $email);
     $email->send();
 }
Example #23
0
 public static function exception($exception, $trace = true)
 {
     static::log($exception);
     ob_get_level() and ob_end_clean();
     $message = $exception->getMessage();
     $file = $exception->getFile();
     $code = $exception->getCode();
     $response = "<html>\n<h2>Unhandled Exception</h2>\n<h3>Message:</h3>\n<pre>(" . $code . ") " . $message . "</pre>\n<h3>Location:</h3>\n<pre>" . $file . " on line " . $exception->getLine() . "</pre>\n";
     if ($trace) {
         $response .= "<h3>Stack Trace:</h3>\n<pre>" . $exception->getTraceAsString() . "</pre>\n";
     }
     $response .= "</html>";
     Response::code(500);
     if (Config::item("errors", "show", false)) {
         echo $response;
     }
     if (Config::item("errors", "email", false) && !Request::isLocal() && !Request::isPreview()) {
         $e = new Email();
         $e->from = Config::item("errors", "emailFrom", "*****@*****.**");
         $e->to = Config::item("errors", "emailTo", "*****@*****.**");
         $e->subject = URL::root() . " - erro!";
         $e->content = $response;
         $e->send();
     }
     return exit(1);
 }
 /**
  * Salvar e enviar o registro de contato
  */
 public function enviar()
 {
     $this->salvar();
     # Enviar por e-mail
     if (class_exists('Email')) {
         if ($this->modelo->assunto > 0) {
             $ma = new ContatoM\AssuntoContato();
             $la = end($ma->listar("assunto_contato_id = {$this->modelo->assunto}", null, 'assunto_contato_descr, assunto_contato_email'));
             $as = $la['assunto_contato_descr'];
             $pa = $la['assunto_contato_email'];
         } else {
             $as = MSG_NAO_INFORMADO;
             $pa = '*****@*****.**';
         }
         // Fim if
         # Montar o assunto e o corpo do e-mail
         $assunto = sprintf(TXT_EMAIL_ASSUNTO_CONTATOSITE, $h = filter_input(INPUT_SERVER, 'HTTP_HOST'), $as);
         $corpo = sprintf(TXT_EMAIL_CONTEUDO_CONTATOSITE, $h, $this->modelo->nome, $this->modelo->email, $this->modelo->telefone, $as, nl2br($this->modelo->mensagem));
         /*
          * Enviar o e-mail utilizando a configuração feita pelo Painel-DL
          */
         $conf_site = new GeralM\ConfiguracaoSite();
         $om = new \Email();
         $e = $om->enviar($pa, $assunto, $corpo, $conf_site->getEmail());
         $om->gravarLog(__CLASS__, $this->modelo->bd_tabela, $this->modelo->id, $assunto, $corpo, $pa);
         if (!$e) {
             throw new \DL3Exception(sprintf(ERRO_CONTATOSITE_ENVIO_EMAIL, $om->exibirLog()), 1500);
         }
         // Fim if
     }
     // Fim if
     \Funcoes::mostrarMsg(SUCESSO_CONTATOSITE_ENVIADO, '-sucesso');
 }
Example #25
0
 public static function fromContactUs(&$return)
 {
     $message = $_POST['contact_text'];
     $sender = $_POST['contact_email'];
     if (!filter_var($sender, FILTER_VALIDATE_EMAIL)) {
         /* invalid email */
         $return['field'] = 'contact_email';
         $return['error'] = 'Invalid email!';
         return;
     }
     if (strlen($message) < 20) {
         /* invalid email */
         $return['field'] = 'contact_text';
         $return['error'] = 'Too little information.';
         return;
     }
     if (isset($_SESSION['contacted']) && $_SESSION['contacted'] === true) {
         $return['error'] = 'You can only contact us once every session.<br>This is to avoid spammers.';
         return;
     }
     $sender = filter_var($sender, FILTER_SANITIZE_EMAIL);
     $email = new Email();
     $email->message = $message;
     $email->sender = $sender;
     $email->insert();
     //mail("*****@*****.**","pasted.at - Contact Us",$message,"From: $email\n");
     $_SESSION['contacted'] = true;
     $return['sucess'] = true;
 }
Example #26
0
 public function mainAction()
 {
     // inicialize supporting classes
     $connection = new Connection();
     $email = new Email();
     $service = new Service();
     $service->showAds = false;
     $render = new Render();
     $response = new Response();
     $utils = new Utils();
     $wwwroot = $this->di->get('path')['root'];
     // get valid people
     $people = $connection->deepQuery("\n\t\t\tSELECT email, username, first_name, last_access\n\t\t\tFROM person\n\t\t\tWHERE active=1\n\t\t\tAND email not in (SELECT DISTINCT email FROM delivery_dropped)\n\t\t\tAND DATE(last_access) > DATE('2016-05-01')\n\t\t\tAND email like '%.cu'\n\t\t\tAND email not like '*****@*****.**'");
     // send the remarketing
     $log = "";
     foreach ($people as $person) {
         // get the email address
         $newEmail = "apretaste+{$person->username}@gmail.com";
         // create the variabels to pass to the template
         $content = array("newemail" => $newEmail, "name" => $person->first_name);
         // create html response
         $response->setEmailLayout("email_simple.tpl");
         $response->createFromTemplate('newEmail.tpl', $content);
         $response->internal = true;
         $html = $render->renderHTML($service, $response);
         // send the email
         $email->sendEmail($person->email, "Sorteando las dificultades, un email lleno de alegria", $html);
         $log .= $person->email . "\n";
     }
     // saving the log
     $logger = new \Phalcon\Logger\Adapter\File("{$wwwroot}/logs/newemail.log");
     $logger->log($log);
     $logger->close();
 }
Example #27
0
 /**
  * public queueNewUser($email, $password)
  *
  * Creates a new user and stores it in the TEMP database, setting
  * the local object's data. It then sends an email with an activation links.
  * 
  * Returns true on success.
  */
 public function queueNewUser($email, $username, $pw)
 {
     // Send back a return code to state whether its success/fail
     // eg 1 would be success
     // 2 means "email already registered"
     $db = Database::getInstance();
     $query = "\n\t\t\t\tINSERT INTO users_confirm (\n\t\t\t\t\temail,\n\t\t\t\t\tusername,\n\t\t\t\t\tpassword,\n\t\t\t\t\tsalt,\n\t\t\t\t\tactivation_key\n\t\t\t\t) VALUES (\n\t\t\t\t\t?,\n\t\t\t\t\t?,\n\t\t\t\t\t?,\n\t\t\t\t\t?,\n\t\t\t\t\t?\n\t\t\t\t)\n\t\t\t";
     $salt = dechex(mt_rand(0, 2147483647)) . dechex(mt_rand(0, 2147483647));
     // This hashes the password with the salt so it can be stored securely.
     $password = hash('sha256', $pw . $salt);
     // Next we hash the hash value 65536 more times.  The purpose of this is to
     // protect against brute force attacks.  Now an attacker must compute the hash 65537
     // times for each guess they make against a password, whereas if the password
     // were hashed only once the attacker would have been able to make 65537 different
     // guesses in the same amount of time instead of only one.
     for ($round = 0; $round < 65536; $round++) {
         $password = hash('sha256', $password . $salt);
     }
     // Uncomment to actually register accounts
     $key = md5(time());
     $db->query($query, array($email, $username, $password, $salt, $key));
     $result = $db->firstResult();
     // Send email
     $em = new Email();
     $em->sendEmail($email, "Confirm your account", "This is an email test, please use this key to register: " . $key, true);
     return true;
 }
Example #28
0
 public function forgotPassword($data)
 {
     $saveData = array();
     $email = $data['email'];
     $respone = array();
     $options = array('conditions' => array('User.email' => $email));
     $user = $this->find("first", $options);
     if ($user) {
         $resetCode = Security::hash(String::uuid(), 'sha1', true);
         $url = Router::url(array('controller' => 'users', 'action' => 'resetPassword'), true) . '?code=' . $resetCode;
         //Removing any previously generated
         $this->ResetPassword->deleteAll(array('ResetPassword.user_id' => $user['User']['id']), false);
         //saving validation code
         $saveData['ResetPassword'] = array('user_id' => $user['User']['id'], 'reset_code' => $resetCode);
         $status = $this->ResetPassword->saveAll($saveData, array('validate' => false));
         if ($status) {
             $Email = new Email();
             $message = 'Reset password';
             $message .= "Copy and Paste following url in your browser:\n";
             $message .= $url;
             if (SEND_EMAIL) {
                 $emailStatus = $Email->sendEmail($email, $message, EMAIL_TPL_RESET_PASSWORD);
             } else {
                 $emailStatus = true;
             }
             if ($emailStatus) {
                 return array('status' => true, 'success_msg' => USER_RESET_PASSWORD_SUCCESS);
             }
         } else {
             return array('status' => false, 'errors' => USER_ERR_RESET_PASSWORD_FAILED);
         }
     } else {
         return array('status' => false, 'errors' => USER_ERR_EMAIL_NOT_REGISTERED);
     }
 }
Example #29
0
 /**
  * 系统通知发送函数
  *
  * @param int $receiver_id 接受人编号
  * @param string $tpl_code 模板标识码
  * @param array $param 内容数组
  * @param bool $flag 是否遵从系统设置
  * @return boolean
  */
 protected function send_notice($receiver_id, $tpl_code, $param, $flag = true)
 {
     $mail_tpl_model = Model('mail_templates');
     $mail_tpl = $mail_tpl_model->getOneTemplates($tpl_code);
     if (empty($mail_tpl) || $mail_tpl['mail_switch'] == 0) {
         return false;
     }
     $member_model = Model('member');
     $receiver = $member_model->infoMember(array('member_id' => $receiver_id));
     if (empty($receiver)) {
         return false;
     }
     $subject = ncReplaceText($mail_tpl['title'], $param);
     $message = ncReplaceText($mail_tpl['content'], $param);
     //根据模板里面确定的通知类型采用对应模式发送通知
     $result = false;
     switch ($mail_tpl['type']) {
         case '0':
             $email = new Email();
             $result = true;
             if ($flag and $GLOBALS['setting_config']['email_enabled'] == '1' or $flag == false) {
                 $result = $email->send_sys_email($receiver['member_email'], $subject, $message);
             }
             break;
         case '1':
             $model_message = Model('message');
             $param = array('member_id' => $receiver_id, 'to_member_name' => $receiver['member_name'], 'msg_content' => $message, 'message_type' => 1);
             $result = $model_message->saveMessage($param);
             break;
     }
     return $result;
 }
Example #30
0
 /**
  * Is this users email verified?
  *
  * @param $user_id
  *
  * @return bool
  */
 public function EmailVerified($user_id)
 {
     if ($this->email->IsVerified($user_id)) {
         return true;
     }
     return false;
 }