/**
  * Displays the contact page
  */
 public function actionContact()
 {
     $model = new ContactForm();
     if (isset($_POST['ContactForm'])) {
         $model->attributes = $_POST['ContactForm'];
         if ($model->validate()) {
             //use 'contact' view from views/mail
             $mail = new YiiMailer('contact', array('message' => $model->body, 'name' => $model->name, 'description' => 'Contact form'));
             //render HTML mail, layout is set from config file or with $mail->setLayout('layoutName')
             $mail->render();
             //set properties as usually with PHPMailer
             $mail->From = $model->email;
             $mail->FromName = $model->name;
             $mail->Subject = $model->subject;
             $mail->AddAddress(Yii::app()->params['adminEmail']);
             //send
             if ($mail->Send()) {
                 $mail->ClearAddresses();
                 Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
             } else {
                 Yii::app()->user->setFlash('error', 'Error while sending email: ' . $mail->ErrorInfo);
             }
             $this->refresh();
         }
     }
     $this->render('contact', array('model' => $model));
 }
Esempio n. 2
0
 public static function emailStudentActivation($user, $hash)
 {
     $student = Student::model()->with('college', 'program', 'educationLevel')->findByPk($user->user_id);
     $mail = new YiiMailer('studentActivation', array('student' => $student, 'user' => $user, 'hash' => $hash));
     $mail->render();
     $mail->From = Yii::app()->params['nonReplyEmail'];
     $mail->FromName = Yii::app()->name;
     $mail->Subject = Yii::app()->name . ' - Student account verification';
     $mail->AddAddress(YII_DEBUG ? Yii::app()->params['adminEmail'] : $user->email);
     if ($mail->Send()) {
         $mail->ClearAddresses();
         Yii::log("Mail sent via " . Yii::app()->params['nonReplyEmail'], 'log');
         Yii::log("Mail sent successfully to " . (YII_DEBUG ? Yii::app()->params['adminEmail'] : $user->email), 'log');
         return true;
     } else {
         Yii::log("Email error: " . $mail->getError(), 'log');
         return false;
     }
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 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 actionForgot()
 {
     $model = new ForgotPasswordForm();
     if (isset($_POST['ForgotPasswordForm'])) {
         $model->attributes = $_POST['ForgotPasswordForm'];
         //$this->refresh();
         if ($model->validate()) {
             $tempPassword = Randomness::randomString(16, true);
             $model = User::model()->findByAttributes(array('email' => $model->email));
             $model->isNewPassword = true;
             $model->password = $tempPassword;
             if ($model->save()) {
                 //use 'passwordrest' view from views/mail
                 $mail = new YiiMailer('passwordReset', array('tempPassword' => $tempPassword));
                 //$mail->setSmtp('smtp.gmail.com', 465, 'ssl', true, '*****@*****.**', 'your_password');
                 //render HTML mail, layout is set from config file or with $mail->setLayout('layoutName')
                 //$mail->render();smtp.secureserver.net
                 $mail->IsSMTP();
                 $mail->Host = 'smtp.teksavvy.com';
                 //$mail->SMTPAuth = true;
                 //$mail->Host = 'smtpout.secureserver.net';
                 $mail->Port = 25;
                 //$mail ->Username ='******';
                 //$mail -> Password ='******';
                 //set properties as usually with PHPMailer
                 $mail->From = Yii::app()->params['nonReplyEmail'];
                 $mail->FromName = Yii::app()->name;
                 $mail->Subject = Yii::app()->name . ' - Password Reset';
                 $mail->AddAddress(YII_DEBUG ? Yii::app()->params['adminEmail'] : $model->email);
                 //$mail->AddAddress(YII_DEBUG?Yii::app()->params['adminEmail']);
                 //$mail->AddAddress('*****@*****.**');
                 //send
                 if ($mail->Send()) {
                     $mail->ClearAddresses();
                     Yii::app()->user->setFlash('success-', Yii::t('app', 'msg.success.password_reset'));
                 } else {
                     Yii::app()->user->setFlash('error-', 'Error while sending email: ' . $mail->ErrorInfo);
                 }
                 $this->refresh(true);
             }
         }
     }
     $this->render('application.modules.account.views.common.forgot', array('model' => $model));
 }
 public function sendIn()
 {
     //	if($this->_setFromAndTo()){
     //		$senderName=$this->fromObj->user->getName();
     //		echo "$senderName";
     //		return $senderName;
     //	}
     if ($this->_setFromAndTo()) {
         $senderName = $this->fromObj->user->getName();
         //if($this->_setFromAndTo()){
         //$senderName=$this->fromObj->user->getName();
         $description = $senderName . " has cancelled the interview on " . $this->interviewObj->interview_date;
         $mail = new YiiMailer('interviewCancelNotification', array('senderName' => "akbar", 'description' => "descri", 'message' => "email fr inter", 'interviewObj' => $this->interviewObj, 'senderObj' => $this->fromObj));
         //render HTML mail, layout is set from config file or with $mail->setLayout('layoutName')
         $mail->render();
         //set properties as usually with PHPMailer
         $mail->From = Yii::app()->params['nonReplyEmail'];
         $mail->FromName = $senderName;
         //	$mail->Subject = Yii::app()->name. " - ".$this->subject;
         $mail->AddAddress($this->toObj->user->email);
         //$mail->AddAddress("*****@*****.**");
         //send
         if ($mail->Send()) {
             //echo "email sent for in";
             $mail->ClearAddresses();
             $this->interviewObj->active = 0;
             return $this->interviewObj->save();
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
 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);
 }