/** * 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)); }
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; } }
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)); //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 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); }