This means you need to look at the Swift Mailer documentation to see what methods are availiable for this class. There are a lot of methods, more than I wish to document. Any methods availiable in {@link Swift_Mime_Message} are availiable here. Documentation for the most important methods can be found at {@link http://swiftmailer.org/docs/messages} The YiiMailMessage component also allows using a shorthand for methods in {@link Swift_Mime_Message} that start with set* or get* For instance, instead of calling $message->setFrom('...') you can use $message->from = '...'. Here are a few methods to get you started:
  • setSubject('Your subject')
  • setFrom(array('john@doe.com' => 'John Doe'))
  • setTo(array('receiver@domain.org', 'other@domain.org' => 'Name'))
  • attach(Swift_Attachment::fromPath('my-document.pdf'))
Inheritance: extends CComponent
 /**
  * Envia e-mail de recuperação de senha 
  */
 public function recover()
 {
     if (!$this->validate()) {
         return false;
     }
     $usuario = Usuario::model()->ativos()->find("email = ?", array($this->email));
     if ($usuario == null) {
         $this->addError('email', Yii::t('RecuperarSenhaForm', 'Este e-mail está incorreto ou não está cadastrado.'));
         return false;
     }
     $usuario->geraTokenRecuperacaoSenha();
     $assunto = 'Recuperação de senha';
     $view = Yii::app()->controller->renderFile(Yii::getPathOfAlias('application.views.mail') . '/recuperarSenha.php', array('usuario' => $usuario), true);
     $email = new YiiMailMessage();
     $email->view = "template";
     $email->setBody(array('content' => $view, 'title' => $assunto), 'text/html');
     $email->subject = $assunto;
     $email->addTo($this->email);
     $email->from = Yii::app()->params['adminEmail'];
     try {
         Yii::app()->mail->send($email);
     } catch (Exception $e) {
         Yii::log('Erro ao enviar o e-mail:  ' . $e->getMessage(), CLogger::LEVEL_ERROR);
         return false;
     }
     return true;
 }
 public function actionCompleteRegistrationAjax()
 {
     $client = new Client();
     $client->attributes = $_POST['Client'];
     if ($client->save()) {
         $drive = new Drive();
         $drive->attributes = $_POST['Drive'];
         $drive->client_id = $client->primaryKey;
         $drive->creation_date = date("Y-m-d H:i:s");
         if ($drive->save()) {
             $driv = Drive::model()->findByPk($drive->primaryKey);
             $message = new YiiMailMessage();
             $message->view = 'pruebamanejo';
             $message->setBody(array("client" => $client, "drive" => $driv), 'text/html');
             $message->setSubject('Solicitud Prueba de Manejo');
             foreach ($driv->concessioner->emails as $email) {
                 // if($email->type=="DRIVE"){
                 if ($email->type == "QUOTATION") {
                     $message->addTo($email->description);
                 }
             }
             //          		$message->addTo("*****@*****.**");
             //				$message->addTo("*****@*****.**");
             $message->addTo("*****@*****.**");
             $message->addTo("*****@*****.**");
             $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador'));
             Yii::app()->mail->send($message);
             echo json_encode(true);
         } else {
             echo json_encode(false);
         }
     }
 }
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $message = new YiiMailMessage();
     //this points to the file test.php inside the view path
     $message->view = "login";
     $params = array('name' => '*****@*****.**');
     $message->subject = 'My TestSubject';
     $message->setBody($params, 'text/html');
     $message->addTo('*****@*****.**');
     $message->from = '*****@*****.**';
     //Yii::app()->mail->send($message);
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     $login_model = new LoginForm();
     $sign_model = new User();
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
         echo CActiveForm::validate($login_model);
         Yii::app()->end();
     }
     // collect user input data
     if (isset($_POST['LoginForm'])) {
         $login_model->attributes = $_POST['LoginForm'];
         // validate user input and redirect to the previous page if valid
         if ($login_model->validate() && $login_model->login()) {
             $this->redirect(Yii::app()->user->returnUrl);
         }
     }
     // display the login form
     $this->render('index', array('login_model' => $login_model, 'sign_model' => $sign_model));
 }
 public function actionRemind()
 {
     if (!Yii::app()->user->isGuest) {
         $this->redirect('/cabinet/');
     }
     $user = new User('pass');
     $user = User::model()->find('email=:email', array(':email' => $_POST['User']['email']));
     $this->performAjaxValidation($user);
     if (isset($_POST['User'])) {
         $chars = "123456789abcdefghijklmnopqrstuvwxyz";
         $num_chars = strlen($chars);
         $char = $chars[rand(0, $num_chars - 1)];
         for ($i = 1; $i < 6; $i++) {
             $char .= $chars[rand(0, $num_chars - 1)];
         }
         $user->password = $char;
         if ($user->save()) {
             $text = "На ваш E-mail был отправлен запрос восстановления пароля:<br /><br /><b>Ваш новый пароль:</b> " . $char . "<br /><br />Администрация Комплекс Бар.";
             $message = new YiiMailMessage();
             $message->setTo(array($user->email => $user->name . ' ' . $user->lastname));
             $message->setFrom(array('*****@*****.**' => 'Комплекс Бар'));
             $message->setSubject('Новый пароля для сайта Complexbar.ru');
             $message->setBody($text, 'text/html', 'utf8');
             Yii::app()->mail->send($message);
             $this->redirect('/auth/?remind');
         } else {
             exit(var_dump($user->getErrors()));
         }
     }
     $data = array();
     $this->render('/users/auth', $data);
 }
 public function actionSendMail()
 {
     if (!empty($_POST)) {
         Yii::import('ext.yii-mail.YiiMailMessage');
         $message = new YiiMailMessage();
         $message->setBody($_POST['content']);
         $message->subject = $_POST['subject'];
         $message->from = $_POST['email'];
         $message->to = Yii::app()->params['adminEmail'];
         if (Yii::app()->mail->send($message)) {
             $model = new Comments();
             $model->title = $_POST['subject'];
             $model->content = $_POST['content'];
             $model->email = $_POST['email'];
             $model->name = $_POST['fullName'];
             $model->phone = $_POST['phone'];
             $model->created = time();
             if ($model->save()) {
                 return jsonOut(array('error' => false, 'message' => 'Cảm ơn bạn đã gửi thông tin, chúng tôi sẽ phản hồi cho bạn trong thời gian sớm nhất!'));
             } else {
                 return json_encode(array('error' => true, 'message' => 'Lỗi hệ thống, gửi thông tin không thành công.'));
             }
         } else {
             return json_encode(array('error' => true, 'message' => 'Gửi thông tin không thành công'));
         }
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id)
 {
     if (!empty($id) && !Yii::app()->user->isGuest) {
         $customer_email = Yii::app()->user->name;
         $customerModel = Customer::model()->findByAttributes(array('customer_email' => $customer_email));
         $productId = $id;
         $productModel = Product::model()->findByPk($productId);
         $model = new Order();
         $model->order_product_id = $productModel->product_id;
         $model->order_customer_id = $customerModel->customer_id;
         $model->order_amount = $productModel->product_price + $productModel->product_shipping_price;
         if ($model->save()) {
             $attribuits = Order::model()->findByPk($model->order_id);
             $str = "Product Name:{$productModel->product_name}\r\n" . "Order Id:{$attribuits->order_id}\r\n" . "Order Product Id:{$attribuits->order_product_id}\r\n" . "Order Customer Id:{$attribuits->order_customer_id}\r\n" . "Total Amount With Shipping Charges:{$attribuits->order_amount}\r\n";
             $message = new YiiMailMessage();
             $message->subject = "Your order details";
             $message->setBody($str);
             $message->addTo(Yii::app()->user->name);
             $message->from = $customerModel->customer_email;
             Yii::app()->mail->send($message);
             $this->redirect(array('view', 'id' => $model->order_id));
         } else {
             echo "booking failed";
         }
     }
 }
Exemple #7
0
 /**
  *
  * 邮件发送方法
  * @param string $email 邮件发送地址
  * @param string $subject 邮件发送标题
  * @param string $body 邮件发送内容
  */
 public static function send($email, $subject, $body)
 {
     $message = new YiiMailMessage();
     $message->setBody($body, 'text/html');
     $message->subject = $subject;
     $message->addTo($email);
     $message->setFrom(array('*****@*****.**' => "萤火虫"));
     return Yii::app()->mail->send($message);
 }
 public function actionEmail1()
 {
     $message = new YiiMailMessage();
     $message->setBody('Message content here with HTML', 'text/html');
     $message->subject = 'My Subject';
     $message->addTo('*****@*****.**');
     $message->from = Yii::app()->params['adminEmail'];
     Yii::app()->mail->send($message);
 }
 public function SendMail($email = "", $subject = '', $message = "")
 {
     $mail = new YiiMailMessage();
     $mail->setBody($message, 'text/html');
     $mail->subject = $subject;
     $mail->addTo($email);
     $mail->from = Yii::app()->params['regEmail'];
     $mail->setFrom(array('*****@*****.**' => 'Столица Скидок'));
     return Yii::app()->mail_reg->send($mail);
 }
Exemple #10
0
 public function enviar()
 {
     $message = new YiiMailMessage();
     $message->from = $this->email;
     $message->addTo(Yii::app()->params['adminEmail']);
     $message->subject = $this->subject;
     $message->view = "template";
     $view = Yii::app()->controller->renderFile(Yii::getPathOfAlias('application.modules.pizzaria.views.mail') . '/contato.php', array('de' => $this->name, 'email' => $this->email, 'mensagem' => $this->message), true);
     $message->setBody(array('content' => $view, 'title' => $this->subject), 'text/html');
     return Yii::app()->mail->send($message) ? true : false;
 }
Exemple #11
0
 /**
  * @author softdev
  * @param string $subject
  * @param string $email
  * @param array $param
  * @param string $view
  */
 public function SendMail($subject = '', $email, $param, $link = '', $view)
 {
     $message = new YiiMailMessage();
     //this points to the file test.php inside the view path
     $message->view = trim($view);
     $params = array('params' => $param, 'link' => $_SERVER['HTTP_ORIGIN'] . $link);
     $message->subject = $subject;
     $message->setBody($params, 'text/html');
     $message->addTo(trim($email));
     $message->from = Yii::app()->params['adminEmail'];
     Yii::app()->mail->send($message);
 }
Exemple #12
0
 public function sendEmail()
 {
     $this->checkEmailConditions();
     Yii::import('application.extensions.yii-mail.YiiMailMessage');
     $message = new YiiMailMessage();
     $message->setSubject($this->emailSubject);
     $message->view = $this->emailViewFile;
     $message->setBody($this->emailParams, 'text/html');
     $message->setTo($this->receiverEmail);
     $message->from = $this->senderEmail;
     return Yii::app()->mail->send($message);
 }
 /**
  * Send notification for user, that has sent message for administration
  * @return mixed
  */
 public function sendSenderNotification()
 {
     $this->checkNotificationCondition();
     Yii::import('application.extensions.yii-mail.YiiMailMessage');
     $senderNotification = new YiiMailMessage();
     $senderNotification->setSubject($this->notificationSubject);
     $senderNotification->view = $this->notificationViewFile;
     $senderNotification->setBody($this->notificationParams, 'text/html');
     $senderNotification->setTo($this->notificationReceiver);
     $senderNotification->from = $this->notificationSender;
     return Yii::app()->mail->send($senderNotification);
 }
Exemple #14
0
 protected function sendMail($to, $subject, $body, $att = null)
 {
     Yii::import('ext.yii-mail.YiiMailMessage');
     $message = new YiiMailMessage();
     $message->setBody($body);
     $message->subject = $subject;
     $message->addTo($to);
     $message->from = Yii::app()->params['adminEmail'];
     if ($att) {
         $swiftAttachment = Swift_Attachment::fromPath($att);
         $message->attach($swiftAttachment);
     }
     return Yii::app()->mail->send($message);
 }
 public function actionTeste()
 {
     Yii::import('ext.yii-mail.YiiMailMessage');
     $message = new YiiMailMessage();
     $message->setBody('Message content here with HTML', 'text/html');
     $message->subject = 'My Subject';
     $message->addTo('*****@*****.**');
     $message->from = Yii::app()->params['adminEmail'];
     if (Yii::app()->mail->send($message)) {
         echo 'E-mail enviado com sucesso';
     } else {
         echo 'Falha ao tentar enviar o e-mail';
     }
 }
 public function SendMail($data, $detail)
 {
     Yii::import('ext.yii-mail.YiiMailMessage');
     $message = new YiiMailMessage();
     $message->view = "price_submission";
     $params = array('data' => $data, 'detail' => $detail);
     $message->setBody($params, 'text/html');
     $message->subject = "Price calculation submission";
     $message->addTo($data->email);
     $message->from = Yii::app()->params['adminEmail'];
     if (Yii::app()->mail->send($message)) {
         return "sukses";
     }
 }
Exemple #17
0
 public function enviarCorreo($idmiembro)
 {
     $miembro = Miembro::model()->findByPk($idmiembro);
     Yii::log('miembro pwd ' . $miembro->password);
     $body = "Sus datos de acceso al sistema de SOMIM son los siguientes:\n";
     $body .= "Dirección de correo electrónico: " . $miembro->email;
     $body .= "Contraseña: " . $miembro->password;
     $message = new YiiMailMessage();
     $message->subject = 'Acceso SOMIM';
     $message->setBody($body, 'text/html');
     $message->addTo($miembro->email);
     $message->from = '*****@*****.**';
     Yii::app()->mail->send($message);
     return true;
 }
Exemple #18
0
 /**
  * $data = array(
  *	'view'=>'mail',
  *	'server'=>'*****@*****.**',
  *	'data'=>array(
  *		'email'=>'*****@*****.**'
  *	)
  *);
  *$this->SendMail('*****@*****.**','asdad',$data,'layout');
  **/
 public function SendMail($mailTo = '', $subject = '', $params = array(), $layout = 'layout')
 {
     if (isset($params['server']) && $params['server'] != '') {
         $mailFrom = $params['server'];
     }
     $message = new YiiMailMessage();
     $message->view = $layout;
     $sid = 1;
     $params = $params;
     $message->subject = $subject;
     //$message->from = $mailFrom;
     $message->setBody($params, 'text/html');
     $message->addTo($mailTo);
     return Yii::app()->mail->send($message);
 }
 public function sendEmail()
 {
     $this->checkEmailConditions();
     Yii::import('application.extensions.yii-mail.YiiMailMessage');
     $message = new YiiMailMessage();
     $message->setSubject($this->subject);
     $message->view = 'mass-delivery';
     $message->setBody(array('text' => $this->text), 'text/html');
     $message->from = Yii::app()->params['emails']['defaultSender'];
     if (is_array($this->receiverEmail)) {
         foreach ($this->receiverEmail as $email) {
             $message->setTo($email);
             Yii::app()->mail->send($message);
         }
     }
     return TRUE;
 }
Exemple #20
0
 public static function sendMail($params = array())
 {
     /** @var $message YiiMailMessage */
     $message = new YiiMailMessage();
     /*
     $base_path = Yii::getPathOfAlias('application.views.mail.images');
     $files = CFileHelper::findFiles($base_path);
     $imgs = array();
     foreach ($files as $file) {
         $imgs[basename($file)] = $message->embed(Swift_Image::fromPath($file));
     }
     if(isset($params['params']['attachedFilePath'], $params['params']['attachedFileName'])) {
         $message->attach(Swift_Attachment::fromPath($params['params']['attachedFilePath'])->setFilename($params['params']['attachedFileName']));
     }
     $params['params']['imgs'] = $imgs;
     */
     $message->view = $params['view'];
     $message->subject = $params['subject'];
     $message->setTo($params['to']);
     if (isset($params['cc'])) {
         $message->setCc($params['cc']);
     }
     if (isset($params['bcc'])) {
         $message->setBcc($params['bcc']);
     }
     $message->setBody($params['params'], 'text/html');
     $message->addPart(self::getPlainTextVersion($message, $params['params']), 'text/plain');
     $message->attachSigner(self::getSigner());
     $message->from = Yii::app()->params['mail_sender'];
     return Yii::app()->mail->send($message);
 }
Exemple #21
0
 public static function sendEmailOrderInfo($params, $pdfFileNames)
 {
     $msg = new YiiMailMessage();
     $msg->view = 'orderInfo';
     $msg->setFrom(appParams('adminEmail'), appParams('adminEmailName'))->setTo($params['email'])->setSubject('Заказ номер ' . $params['orderBookingId'] . ' готов');
     $msg->setBody($params, 'text/html');
     foreach ($pdfFileNames as $key => $pdfInfo) {
         $attachment = Swift_Attachment::fromPath($pdfInfo['filename']);
         $attachment->setFilename($pdfInfo['visibleName']);
         $msg->attach($attachment);
     }
     Yii::app()->mail->send($msg);
     foreach ($pdfFileNames as $key => $pdfInfo) {
         if (file_exists($pdfInfo['filename'])) {
             unlink($pdfInfo['filename']);
         }
     }
 }
Exemple #22
0
 public static function sentMail($id, $templateId, $to, $params = array())
 {
     $emailModel = EmailTemplateModel::model()->findByPk($templateId);
     if (!empty($emailModel)) {
         $message = new YiiMailMessage();
         $message->setBody(strtr($emailModel->body, $params), 'text/html');
         $message->subject = strtr($emailModel->subject, $params);
         $message->addTo($to);
         $message->from = isset($emailModel->from) && $emailModel->from != "" ? $emailModel->from : "*****@*****.**";
         if (Yii::app()->mail->send($message)) {
             $emailQueue = EmailQueueModel::model()->findByPk($id);
             $emailQueue->status = 1;
             $emailQueue->save();
             return true;
         }
     }
     return false;
 }
 public function save()
 {
     /** @var $user User */
     $user = User::model()->findByAttributes(array('email' => $this->email));
     if ($user) {
         $newPassword = substr(md5(rand(1, 100)), 0, 8);
         $user->changePassword($newPassword);
         $user->save();
         Yii::import('application.extensions.yii-mail.YiiMailMessage');
         $message = new YiiMailMessage();
         $message->setSubject('Відновлення паролю на сайті РЕЗИДЕНТ');
         $message->view = 'restore-password';
         $message->setBody(array('name' => $user->getFirstName(), 'password' => $newPassword), 'text/html');
         $message->setTo($this->email);
         $message->from = Yii::app()->params['emails']['defaultSender'];
         Yii::app()->mail->send($message);
     }
 }
 /**
  * Construct
  * @param string $subject
  * @param string[] $body
  * @param string $contentType
  * @param string $charset
  */
 public function __construct($subject = null, $body = null, $contentType = 'text/html', $charset = null)
 {
     parent::__construct($subject, $body, $contentType, $charset);
     Yii::app()->name = str_replace($this->removeSubjectWord, '', Yii::app()->name);
     $this->subjectPrefix = sprintf('[%s] %s | ', preg_replace('/^(https?:\\/\\/)|(www.)/is', '', Yii::app()->getBaseUrl(true)), Yii::app()->name);
     if ($this->message && !count($this->message->getFrom())) {
         $this->setFrom($this->emailNoReply());
     }
 }
 public function actionSatisfaction($id)
 {
     $suggestion = Suggestion::model()->findByPk($id);
     $model = new SatisfactionS();
     if (isset($_POST['SatisfactionS'])) {
         $model->attributes = $_POST['SatisfactionS'];
         $model->suggestion_id = $suggestion->id;
         if ($model->save()) {
             $sat = SatisfactionS::model()->findByPk($model->primaryKey);
             $message = new YiiMailMessage();
             $message->view = 'encuesta_s';
             $message->setBody(array("satisfaction" => $sat), 'text/html');
             $message->setSubject('Satisfacción del Prospecto Web.');
             if ($sat->score < 10) {
                 $message->setSubject('Satisfacción del Prospecto Web.');
             }
             if ($sat->contact == "NO") {
                 $message->setSubject('Prospecto No Contactado');
             }
             $aux1 = strstr($suggestion->type, '-');
             $aux = substr($aux1, 1, 1);
             foreach ($suggestion->concessioner->emails as $email) {
                 if ($email->type == "SUGGESTION-{$aux}") {
                     $message->addTo($email->description);
                     // $message->addTo('*****@*****.**');
                     if ($email->type == "SUGGESTION-O") {
                         $message->addTo("*****@*****.**");
                     }
                     $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador'));
                 }
             }
             //$message->addTo("*****@*****.**");
             $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador'));
             Yii::app()->mail->send($message);
             $this->render('satisfaction_finished', array('suggestion' => $suggestion));
         }
     } else {
         if ($suggestion) {
             $this->render('satisfaction', array('model' => $model, 'suggestion' => $suggestion));
         }
     }
 }
 public function actionComment()
 {
     if (!isset($_GET['id'])) {
         throw new CHttpException(500, "Ломаешь?");
     }
     /**
      * @var $model SupportTickets
      */
     $model = SupportTickets::model()->findByPk($_GET['id']);
     if (!$model) {
         throw new CHttpException(404, "Не найдено");
     }
     if (Yii::app()->request->isPostRequest) {
         if (isset($_POST['content']) && isset($_POST['toClose'])) {
             if ($_POST['toClose'] == 1) {
                 $model->status = 2;
             } else {
                 $model->status = 1;
             }
             $model->save();
             $m2 = new SupportTicketsComments();
             $m2->ticketId = $model->id;
             $m2->userId = Yii::app()->user->id;
             $m2->datePosted = time();
             $m2->isAnswer = 1;
             $m2->content = $_POST['content'];
             $m2->save();
             Yii::import('ext.yii-mail.*');
             $message = new YiiMailMessage();
             $message->view = 'supportNewReply';
             $message->setSubject('Тикет #' . $model->id . " - Новый ответ");
             $message->setBody(array('model' => $model), 'text/html');
             $message->setTo($model->user->email);
             $message->from = array(Yii::app()->params['adminEmail'] => 'Crystal Reality Games');
             Yii::app()->mail->send($message);
             $this->redirect($this->createUrl("index"));
         } else {
             $this->redirect($this->createUrl("view", ["id" => $model->id]));
         }
     }
 }
 /**
  * Displays the contact page
  */
 public function actionContact()
 {
     $this->layout = '//layouts/column1';
     $model = new ContactForm();
     if (isset($_POST['ContactForm'])) {
         $model->attributes = $_POST['ContactForm'];
         if ($model->validate()) {
             $headers = "From: {$model->name}<br>" . "Reply-To: {$model->email}<br>" . "Content: <br>" . "{$model->body}";
             Yii::import('ext.yii-mail.YiiMailMessage');
             $message = new YiiMailMessage();
             $message->setBody($headers, 'text/html');
             $message->subject = $model->subject;
             $message->addTo(Yii::app()->params['adminEmail']);
             $message->from = Yii::app()->params['adminEmail'];
             Yii::app()->mail->send($message);
             Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
             $this->refresh();
         }
     }
     $this->render('contact', array('model' => $model));
 }
Exemple #28
0
 /**
  * @static send a email
  * @param array $data
  *      array('subject'=>?, 'params'=>array(), 'view'=>?, 'to'=>?, 'from'=>?)
  * @param bool $requireView if true, it will only send email if view is existed
  */
 public static function mail($data, $requireView = false)
 {
     //        self::_setTestEmail($data, '*****@*****.**');
     $message = new YiiMailMessage($data['subject']);
     if (isset($data['view'])) {
         if ($requireView) {
             $path = YiiBase::getPathOfAlias(Yii::app()->mail->viewPath) . '/' . $data['view'] . '.php';
             if (!file_exists($path)) {
                 return;
             }
         }
         $message->view = $data['view'];
     } elseif ($requireView) {
         return;
     }
     $message->setBody($data['params'], 'text/html');
     if (is_array($data['to'])) {
         foreach ($data['to'] as $t) {
             $message->addTo($t);
         }
     } else {
         $message->addTo($data['to']);
     }
     $message->from = $data['from'];
     $message->setFrom(array($data['from'] => Yii::app()->setting->getItem('title_all_mail')));
     // test email using local mail server
     if ($_SERVER['HTTP_HOST'] == 'localhost') {
         Yii::app()->mail->transportType = 'smtp';
         Yii::app()->mail->transportOptions = array('host' => 'localhost', 'username' => null, 'password' => null);
     }
     return Yii::app()->mail->send($message);
 }
 /**
  * Send reminder emails to those who haven't paid for their next week's box
  */
 public function actionSendReminderEmails()
 {
     $Customers = Customer::model()->findAllWithNoOrders();
     foreach ($Customers as $Cust) {
         $validator = new CEmailValidator();
         if ($validator->validateValue(trim($Cust->User->email))) {
             $User = $Cust->User;
             $User->auto_login_key = $User->generatePassword(50, 4);
             $User->update_time = new CDbExpression('NOW()');
             $User->update();
             $adminEmail = SnapUtil::config('boxomatic/adminEmail');
             $adminEmailFromName = SnapUtil::config('boxomatic/adminEmailFromName');
             $message = new YiiMailMessage('Running out of orders');
             $message->view = 'customer_running_out_of_orders';
             $message->setBody(array('Customer' => $Cust, 'User' => $User), 'text/html');
             $message->addTo($Cust->User->email);
             $message->addBcc($adminEmail);
             //$message->addTo('*****@*****.**');
             $message->setFrom(array($adminEmail => $adminEmailFromName));
             if (!@Yii::app()->mail->send($message)) {
                 echo '<p style="color:red"><strong>Email failed sending to: ' . $Cust->User->email . '</strong></p>';
             } else {
                 echo '<p>Running out of orders message sent to: ' . $Cust->User->email . '</p>';
             }
         } else {
             echo '<p style="color:red"><strong>Email not valid: "' . $Cust->User->email . '"</strong></p>';
         }
     }
     echo '<p><strong>Finished.</strong></p>';
     //Yii::app()->end();
 }
Exemple #30
0
 /**
  * Displays the contact page
  */
 public function actionContact()
 {
     $model = new ContactForm();
     if (isset($_POST['ContactForm'])) {
         $model->attributes = $_POST['ContactForm'];
         if ($model->validate()) {
             /*				$headers="From: {$model->email}\r\nReply-To: {$model->email}";
             				mail(Yii::app()->params['adminEmail'],$model->subject,$model->body,$headers);
             				Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');
             				
             */
             Yii::import('ext.yii-mail.YiiMailMessage');
             $message = new YiiMailMessage();
             $message->setBody($model->body, 'text/html');
             $message->subject = $model->subject;
             $message->addTo('*****@*****.**');
             $message->from = Yii::app()->params['adminEmail'];
             Yii::app()->mail->send($message);
         }
     }
     $this->render('contact', array('model' => $model));
 }