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