Example #1
0
 protected static function config($subject = false, $message = false)
 {
     Yii::import('ext.phpmailer.JPhpMailer');
     $mail = new JPhpMailer();
     //$mail->IsSMTP(); // telling the class to use SMTP
     $mail->CharSet = 'UTF-8';
     //$mail->SMTPDebug = 2;
     $mail->SMTPAuth = true;
     // enable SMTP authentication
     $mail->SMTPSecure = "ssl";
     // sets the prefix to the servier
     $mail->Host = "smtp.googlemail.com";
     // sets GMAIL as the SMTP server
     $mail->Port = 465;
     // set the SMTP port for the GMAIL server
     $mail->Username = self::$username;
     // GMAIL username
     $mail->Password = self::$password;
     // GMAIL password
     if ($subject) {
         $mail->Subject = $subject;
     }
     if ($message) {
         $mail->MsgHTML($message);
     }
     return $mail;
 }
 public function run($args)
 {
     Yii::import('application.extensions.phpmailer.JPhpMailer');
     $mail = new JPhpMailer();
     $mail->IsSMTP();
     $mail->SMTPDebug = 1;
     $mail->Host = CommonProperties::$SMTP_SENDER_HOST;
     $mail->SMTPAuth = true;
     $mail->Port = "587";
     $mail->SetFrom(CommonProperties::$SMTP_SENDER_FROM_EMAIL);
     $mail->Username = CommonProperties::$SMTP_SENDER_USERNAME;
     $mail->Password = CommonProperties::$SMTP_SENDER_PASSWORD;
     $mail->AddAddress("*****@*****.**");
     $mail->Body = "Test Réussi";
     $mail->Subject = "Mail de test pour la configuration SMTP";
     return $mail->Send();
 }
Example #3
0
    function setDataBuy($vad, $id, $status, $type)
    {
        $model_produk = new TransaksiRequestPembelian();
        $idUsr = Yii::app()->user->getId();
        $profile = TransaksiRegistrasi::model()->get_data_profile($idUsr);
        $profile = (object) $profile;
        $user = Users::model()->findByPk($idUsr);
        $model = GalleryBarang::model()->findByPk($id);
        if ($type == 'POINT' && $user->POINT < $model->HARGA_POINT) {
            return false;
        } else {
            $model_produk->ID_USERS = $idUsr;
            $model_produk->ID_GALLERY_BARANG = $id;
            $model_produk->VAD = $vad;
            $model_produk->STATUS = $status;
            $model_produk->TYPE_PEMBELIAN = $type;
            $model_produk->save(false);
            if ($type == 'CASH') {
                Yii::import('application.extensions.phpmailer.JPhpMailer');
                $mail = new JPhpMailer();
                $mail->isSMTP();
                $mail->Debugoutput = 'html';
                $mail->Host = 'smtp.gmail.com';
                $mail->Port = 587;
                $mail->SMTPSecure = 'tls';
                $mail->SMTPAuth = true;
                $mail->Username = "******";
                $mail->Password = "******";
                $mail->setFrom('*****@*****.**', 'Admin Soniq');
                // $mail->addReplyTo('*****@*****.**', 'First Last');
                $mail->addAddress($profile->EMAIL, $profile->NAMA_LENGKAP);
                $mail->Subject = 'Konfirmasi Pembelian Produk Soniq';
                $mail->MsgHTML('<h1> Hello, ' . $profile->NAMA_LENGKAP . '</h1><br> 
					Anda Request Barang denganKODE BARANG : <b>' . $model->KODE_GALLERY . ' </b> dan 
					 NAMA BARANG : <b>' . $model->NAMA_GALLERY . '</b><br> Silahkan Transfer Biaya Pembelian Sebesar	: <b>' . $model->HARGA_CASH . '</b> Ke Rekening Berikut<br> 
					<br> Virtual ID anda : <b>' . $model_produk->VAD . '</b> <br> Terimakasih... ');
                $mail->send();
            } else {
                if ($type == 'POINT') {
                    $user->POINT = $user->POINT - $model->HARGA_POINT;
                    $user->save();
                }
            }
            return true;
        }
    }
Example #4
0
 public static function send($email, $subject, $message, $from = false)
 {
     if (Yii::app()->request->userHostAddress == '127.0.0.1') {
         return true;
     }
     Yii::import('application.extensions.phpmailer.JPhpMailer');
     $mail = new JPhpMailer();
     $mail->IsSMTP();
     $mail->Host = 'smtp.mandrillapp.com';
     $mail->Port = 587;
     $mail->SMTPSecure = 'tls';
     $mail->SMTPAuth = true;
     $mail->Username = '******';
     $mail->Password = '******';
     $mail->CharSet = 'utf8';
     if (!$from) {
         $mail->SetFrom("*****@*****.**", "FermionAm");
     } else {
         $mail->SetFrom($from);
     }
     $mail->AddAddress($email);
     $mail->Subject = $subject;
     $mail->MsgHTML($message);
     if ($mail->Send()) {
         return true;
     } else {
         echo $mail->ErrorInfo;
         return false;
     }
 }
 public static function SendMailFunction($mail_to, $mail_from, $message = "", $subject = "", $cc = [])
 {
     Yii::import('application.extensions.phpmailer.JPhpMailer');
     $mail = new JPhpMailer();
     $__smtp = $mail->__smtp;
     if (is_null($mail_to)) {
         $mail_to = $__smtp['addreply'];
     }
     if (is_null($mail_from)) {
         $mail_from = $__smtp['addreply'];
     }
     $mail_arr = explode(",", $mail_to);
     if ($subject == "") {
         $subject = Yii::t('trans', 'Site title');
     }
     $mail->IsSMTP();
     $mail->SMTPSecure = 'ssl';
     $mail->Host = $__smtp['host'];
     $mail->SMTPAuth = $__smtp['auth'];
     $mail->Port = $__smtp['port'];
     $mail->Username = $__smtp['username'];
     $mail->Password = $__smtp['password'];
     $mail->AddReplyTo($mail_from, $mail_from);
     $mail->SetFrom($mail_from, $mail_from);
     if (!empty($cc)) {
         if (is_array($cc) && count($cc) == 2) {
             $mail->AddCC($cc[0], $cc[1]);
         } else {
             if (is_array($cc)) {
                 $mail->AddCC($cc[0]);
             } else {
                 $mail->AddCC($cc);
             }
         }
     }
     $mail->Subject = $subject;
     $mail->MsgHTML($message);
     $mail->CharSet = "utf-8";
     foreach ($mail_arr as $email) {
         $mail->AddAddress(trim($email));
     }
     if ($mail->Send()) {
     }
 }
Example #6
0
function sendCheckMail()
{
    try {
        $mail = new JPhpMailer();
        $mail->IsSMTP();
        $mail->Host = CommonProperties::$SMTP_SENDER_HOST;
        $mail->SMTPAuth = true;
        $mail->Port = CommonProperties::$SMTP_SENDER_PORT;
        $mail->SetFrom(CommonProperties::$SMTP_SENDER_FROM_EMAIL);
        $mail->Username = CommonProperties::$SMTP_SENDER_USERNAME;
        $mail->Password = CommonProperties::$SMTP_SENDER_PASSWORD;
        $mail->AddAddress(CommonProperties::$ADMIN_EMAIL);
        $mail->Body = "Test Réussi - " . date("d/m/Y");
        $mail->Subject = "Mail de test pour la configuration SMTP";
        return $mail->Send();
    } catch (Exception $ex) {
        return false;
    }
}
Example #7
0
 protected function sendEmail($email, $subject, $message)
 {
     Yii::import('application.extensions.phpmailer.JPhpMailer');
     $mail = new JPhpMailer();
     $mail->IsSMTP();
     $mail->Host = CommonProperties::$SMTP_SENDER_HOST;
     $mail->SMTPAuth = true;
     $mail->SMTPSecure = "none";
     //"tls";
     $mail->Port = CommonProperties::$SMTP_SENDER_PORT;
     $mail->Username = CommonProperties::$SMTP_SENDER_USERNAME;
     $mail->Password = CommonProperties::$SMTP_SENDER_PASSWORD;
     $src = CommonProperties::$DEV_MODE ? 'dev' : 'prod';
     $mail->SetFrom(CommonProperties::$SMTP_SENDER_FROM_EMAIL, "robot ebiobanques" . $src);
     $mail->Subject = "ebiobanques : " . $subject;
     $mail->Body = $message;
     $mail->addAddress($email);
     $mail->send();
 }
Example #8
0
 /**
  * Generic method for sending an email. Instead of having to call a bunch of code all over over the place
  * This method can be called which should be able to handle almost anything.
  *
  * By calling this method, the SMTP details will automatically be setup as well the notify email and user
  * 
  * @param  Users   $user          The User we are sending the email to
  * @param  string  $subject       The email Subject
  * @param  string  $viewFile      The view file we want to render. Generally this should be in the form //email/<file>
  *                                And should correspond to a viewfile in /themes/<theme>/views/email/<file>
  * @param  array   $content       The content to pass to renderPartial()
  * @param  boolean $return        Whether the output should be returned. The default is TRUE since this output will be passed to MsgHTML
  * @param  boolean $processOutput Whether the output should be processed. The default is TRUE since this output will be passed to MsgHTML
  * @return boolean                Whether or not the email sent sucessfully
  */
 public function sendEmail($user, $subject = "", $viewFile, $content = array(), $return = true, $processOutput = true)
 {
     Yii::import('application.extensions.phpmailer.JPhpMailer');
     $mail = new JPhpMailer();
     $mail->IsSMTP();
     $mail->SMTPAuth = false;
     $smtpHost = Cii::getConfig('SMTPHost', NULL);
     $smtpPort = Cii::getConfig('SMTPPort', NULL);
     $smtpUser = Cii::getConfig('SMTPUser', NULL);
     $smtpPass = Cii::getConfig('SMTPPass', NULL);
     $notifyUser = new stdClass();
     $notifyUser->email = Cii::getConfig('notifyEmail', NULL);
     $notifyUser->displayName = Cii::getConfig('notifyName', NULL);
     if ($smtpHost !== NULL && $smtpHost !== "") {
         $mail->Host = $smtpHost;
     }
     if ($smtpPort !== NULL && $smtpPort !== "") {
         $mail->Port = $smtpPort;
     }
     if ($smtpUser !== NULL && $smtpUser !== "") {
         $mail->Username = $smtpUser;
         $mail->SMTPAuth = true;
     }
     if ($smtpPass !== NULL && $smtpPass !== "" && Cii::decrypt($smtpPass) != "") {
         $mail->Password = Cii::decrypt($smtpPass);
         $mail->SMTPAuth = true;
     }
     if ($notifyUser->email == NULL && $notifyUser->displayName == NULL) {
         $notifyUser = Users::model()->findByPk(1);
     }
     $mail->SetFrom($notifyUser->email, $notifyUser->displayName);
     $mail->Subject = $subject;
     $mail->MsgHTML($this->renderPartial($viewFile, $content, $return, $processOutput));
     $mail->AddAddress($user->email, $user->displayName);
     try {
         return $mail->Send();
     } catch (Exception $e) {
         return false;
     }
     return false;
 }
 public function run($args)
 {
     Yii::import('application.extensions.phpmailer.JPhpMailer');
     if (Yii::app()->params['mailSystemActif'] == true) {
         $models = mailqueue::model()->findAll();
         foreach ($models as $model) {
             $mail = new JPhpMailer();
             $mail->IsSMTP();
             $mail->Host = CommonProperties::$SMTP_SENDER_HOST;
             $mail->SMTPAuth = true;
             $mail->Port = CommonProperties::$SMTP_SENDER_PORT;
             $mail->Username = CommonProperties::$SMTP_SENDER_USERNAME;
             $mail->Password = CommonProperties::$SMTP_SENDER_PASSWORD;
             $mail->SetFrom(CommonProperties::$SMTP_SENDER_FROM_EMAIL, 'cbsd_platform');
             $mail->Subject = $model->subject;
             $mail->AltBody = $model->body;
             $mail->MsgHTML($model->body);
             $mail->AddAddress($model->emailto, $model->emailto);
             $mail->CharSet = 'UTF-8';
             if ($mail->Send()) {
                 $model->delete();
             } else {
                 print_r($mail->ErrorInfo);
             }
         }
     } else {
         echo 'Le système d\'envoi de mail n\'est pas activé';
     }
 }
Example #10
0
 public function notify($recipients, $subject, $message)
 {
     Yii::import('application.extensions.phpmailer.JPhpMailer');
     $mail = new JPhpMailer();
     $mail->IsSMTP();
     //$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
     $mail->Host = Yii::app()->params['mailHost'];
     // using google smtp
     $mail->Port = 465;
     // or 587/465
     $mail->SMTPAuth = true;
     $mail->SMTPSecure = "ssl";
     //only gor gmail
     $mail->Username = Yii::app()->params['adminEmail'];
     //host login name or email
     $mail->Password = Yii::app()->params['hostPassword'];
     $mail->SetFrom('*****@*****.**', Yii::app()->name);
     $mail->Subject = $subject;
     //$mail->AltBody = $message;
     $mail->Body = $message;
     $mail->MsgHTML($message);
     foreach ($recipients as $recipient) {
         $mail->AddAddress($recipient);
     }
     return $mail->Send();
 }
Example #11
0
 public function run($args)
 {
     //  require('CController');
     $fecha = date('Y-m-d');
     $nuevafecha = strtotime('-2 day', strtotime($fecha));
     $criteria = new CDbCriteria();
     $criteria->params = array(':fecha' => date('Y-m-d', $nuevafecha), ':fecha1' => $fecha);
     $criteria->condition = 'fecha_termino between :fecha and :fecha1';
     $tecnicos = UsuarioTecnico::model()->findAll($criteria);
     // $ccc = new CController();
     //if(count($tecnicos) > 0){
     Yii::import('application.extensions.phpmailer.JPhpMailer');
     $mail = new JPhpMailer();
     $mail->IsSMTP();
     $mail->Host = 'smtp.gmail.com';
     $mail->Port = '587';
     $mail->SMTPSecure = 'tls';
     $mail->SMTPAuth = true;
     $mail->Username = '******';
     $mail->Password = '******';
     $mail->SetFrom('*****@*****.**', 'Falcon');
     $mail->Subject = 'Aviso Tecnicos';
     $mail->MsgHTML($this->render('email', array('tecnicos' => $tecnicos), true));
     $mail->AddAddress('*****@*****.**', 'Falcon CK');
     $mail->Send();
     //}
 }
Example #12
0
 /**
  * ttSendMail
  *
  * @param mixed   $subject
  * @param mixed   $altBody
  * @param mixed   $message
  * @param mixed   $toAddress
  * @param mixed   $toName
  * @access public
  * @return void
  */
 public function ttSendMail($subject, $altBody, $message, $toAddress, $toName)
 {
     $mailResource = Yii::app()->mailresource;
     $mailResource->resources['Host'] = Yii::app()->params->mail['host'];
     $mailResource->resources['SMTPAuth'] = Yii::app()->params->mail['smtpauth'];
     $mailResource->resources['Username'] = Yii::app()->params->mail['username'];
     $mailResource->resources['Password'] = Yii::app()->params->mail['password'];
     $mailResource->resources['Port'] = Yii::app()->params->mail['port'];
     $mailResource->resources['From'] = Yii::app()->params->mail['from'];
     $mailResource->resources['FromName'] = Yii::app()->params->mail['fromname'];
     $mailResource->resources['CharSet'] = Yii::app()->params->mail['charset'];
     $mailResource->resources['SMTPSecure'] = Yii::app()->params->mail['smtpsecure'];
     $phpMailer = new JPhpMailer();
     foreach ($mailResource->resources as $mailVar => $value) {
         $phpMailer->{$mailVar} = $value;
     }
     $phpMailer->Subject = $subject;
     $phpMailer->AltBody = $altBody;
     $phpMailer->MsgHTML($message);
     $phpMailer->AddAddress($toAddress, $toName);
     $phpMailer->SetFrom($phpMailer->From, $phpMailer->FromName);
     $phpMailer->IsSMTP();
     if (!$phpMailer->Send()) {
         Yii::log("Mail cannot be sent, check whether a mail agent is installed", "error", self::LOG_CAT);
         return false;
     }
     return true;
 }
Example #13
0
    public function actionConfirmTopUp()
    {
        $id = Yii::app()->user->getId();
        $model = new TransaksiRequestTopupPoint();
        $user = Users::model()->findByPk($id);
        $model->ID_USERS = $id;
        $model->TANGGAL = date('Y-m-d');
        $model->STATUS = 0;
        $model->save();
        $profile = TransaksiRegistrasi::model()->get_data_profile($id);
        $profile = (object) $profile;
        Yii::app()->user->setFlash('Virtual Account', $user->VAS);
        Yii::app()->user->setFlash('Email', $profile->EMAIL);
        if (Yii::app()->user->hasFlash('Virtual Account')) {
            Yii::import('application.extensions.phpmailer.JPhpMailer');
            $mail = new JPhpMailer();
            $mail->isSMTP();
            $mail->Debugoutput = 'html';
            $mail->Host = 'smtp.gmail.com';
            $mail->Port = 587;
            $mail->SMTPSecure = 'tls';
            $mail->SMTPAuth = true;
            $mail->Username = "******";
            $mail->Password = "******";
            $mail->setFrom('*****@*****.**', 'Admin Soniq');
            // $mail->addReplyTo('*****@*****.**', 'First Last');
            $mail->addAddress($profile->EMAIL, $profile->NAMA_LENGKAP);
            $mail->Subject = 'Konfirmasi TopUP Point Soniq';
            $mail->MsgHTML('<h1> Hello, ' . $profile->NAMA_LENGKAP . '</h1><br>
			Silahkan Transfer Biaya ke Virtual Account Anda <b>' . $user->VAS . '</b><br>
			Nilai Point adalah biaya / 5000 <br>
			<br> Terimakasih');
            // $mail->send();
            $this->render('confirm');
        } else {
            $this->redirect(array('point/topup'));
        }
    }
Example #14
0
 public function __construct()
 {
     parent::__construct($exceptions = true);
     ///Eswto permite atrapar los erroes con TRY CATCH, de otro modo siempre habra
     $this->SMTPDebug = false;
     $this->SMTPDebug = yii::app()->settings->get('email', 'email_smtpdebug') + 0;
     //DEBE SER UN ENTERO Y CERO =FALSE
     $this->Host = yii::app()->settings->get('email', 'email_servemail');
     // $this->exceptions = yii::app()->settings->get('email','email_servemail');
     $this->SMTPAuth = true;
     $this->SetLanguage('es');
     $this->Username = yii::app()->settings->get('email', 'email_adminemail');
     $this->Password = '******';
     $this->_copiarausuario = yii::app()->user->um->getFieldValue(Yii::app()->user->id, 'recibecopiasmail') == '1' ? true : false;
     $this->_usarcorreousuario = yii::app()->params['email_usamaildeusuario'] == '1' ? true : false;
 }
 public function enviar(array $from, array $to, $subject, $message)
 {
     $mail = new JPhpMailer();
     $mail->IsSMTP();
     $mail->Host = 'smtp.gmail.com';
     $mail->SetFrom($from[0], $from[1]);
     $mail->Subject = $subject;
     $mail->MsgHTML($message);
     $mail->AddAddress($to[0], $to[1]);
     $mail->Send();
 }
Example #16
0
/**
 * utils.php   file.
 *
 * Collection of utility functions
 * @author Miguel Sanchez <*****@*****.**>
 */
function sendHtmlEmail($toStr, $subject, $content, $ccStr = null)
{
    /* ini_set("SMTP", "mailserver.copservir.com");
        ini_set("smtp_port", "25");
        ini_set("sendmail_from", "mailserver.copservir.com");
        Yii::import('application.extensions.phpmailer.JPhpMailer');
        $mail = new JPhpMailer;
        $mail->isSMTP();
        $mail->Host = 'mailserver.copservir.com';
        $mail->Port = 25;
        $mail->SMTPAuth = false;
        $mail->isHTML(true);
        $mail->CharSet = "UTF-8";
       */
    Yii::import('application.extensions.phpmailer.JPhpMailer');
    $mail = new JPhpMailer();
    $mail->isSMTP();
    $mail->Host = 'smtp.gmail.com';
    $mail->SMTPAuth = true;
    $mail->Username = '******';
    $mail->Password = '******';
    $mail->SMTPSecure = 'tls';
    $mail->Port = 587;
    $mail->isHTML(true);
    $mail->CharSet = "UTF-8";
    $mail->From = Yii::app()->params->correoAdmin;
    $mail->FromName = Yii::app()->name;
    if ($toStr === null) {
        throw new Exception("email receiver is empty");
    }
    $toStr = trim($toStr);
    if (empty($toStr)) {
        throw new Exception("email receiver is empty");
    }
    $toArr = explode(",", $toStr);
    if (empty($toArr)) {
        throw new Exception("email receiver is empty");
    }
    foreach ($toArr as $to) {
        $mail->addAddress($to);
    }
    if ($ccStr !== null) {
        $ccArr = explode(",", $ccStr);
        foreach ($ccArr as $cc) {
            $mail->addCC($cc);
        }
    }
    $mail->Subject = $subject;
    $mail->Body = $content;
    if (!$mail->send()) {
        throw new Exception("Message could not be sent. " . $mail->ErrorInfo);
    }
}
 public function actionEmail3()
 {
     $mail = new JPhpMailer();
     $mail->IsSMTP();
     $mail->Host = 'smtp.mail.yahoo.co.id';
     $mail->SMTPAuth = true;
     $mail->Username = '******';
     $mail->Password = '******';
     $mail->SetFrom('*****@*****.**', 'Peter Kambey');
     $mail->Subject = 'PHPMailer Test Subject via smtp, basic with authentication';
     $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
     $mail->MsgHTML('<h1>JUST A TEST!</h1>');
     $mail->AddAddress('*****@*****.**', 'Peter Kambey');
     $mail->Send();
 }
 public function actionHelp()
 {
     $model = new FEmail();
     $mail = new JPhpMailer();
     $mail->IsSMTP();
     $mail->Host = 'smtp.mail.yahoo.co.id';
     $mail->SMTPAuth = true;
     $mail->Username = '******';
     $mail->Password = '******';
     if (isset($_POST['FEmail'])) {
         $model->attributes = $_POST['FEmail'];
         if ($model->validate()) {
             $mail->SetFrom(Yii::app()->params['userEmail'], 'OTA Bethel');
             $mail->Subject = $model->subject;
             $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
             $mail->MsgHTML($model->body);
             $mail->AddAddress(Yii::app()->params['adminEmail'], 'Peter J. Kambey');
             $mail->Send();
             Yii::app()->user->setFlash('contact', 'Your Email Has Been Send...');
             $this->refresh();
         }
     }
     $this->render('help', array('model' => $model));
 }
Example #19
0
 /**
  * Phương thức Send($strSubject, $strMsgHTML, $arrAddress = array()) dùng để gửi email từ hệ thống
  *
  * @param string $strSubject Subject của email
  * @param string $strMsgHTML Nội dung của email (định dạng HTML)
  * @param array $arrAddress Danh sách địa chỉ đích cần gửi email đến Ex: array(array('abc1\@host.com', 'ABC1'), array('abc2\@host.com', 'ABC2'))
  * @return
  */
 public static function Send($strSubject, $strMsgHTML, $arrAddress = array())
 {
     Yii::import('application.extensions.phpmailer.JPhpMailer');
     $mail = new JPhpMailer();
     $mail->IsSMTP();
     $mail->SMTPAuth = true;
     $mail->Host = Yii::app()->params['mailer']['host'];
     $mail->Port = Yii::app()->params['mailer']['port'];
     $mail->SMTPSecure = Yii::app()->params['mailer']['secure'];
     $mail->Username = Yii::app()->params['mailer']['username'];
     $mail->Password = Yii::app()->params['mailer']['password'];
     $mail->SetFrom(Yii::app()->params['mailer']['username'], Yii::app()->params['mailer']['name']);
     $mail->Subject = $strSubject;
     $mail->MsgHTML($strMsgHTML);
     foreach ($arrAddress as $address) {
         $mail->AddAddress($address[0], $address[1]);
     }
     $mail->Send();
 }
 private function send_notification_email($controller, $user, $uuid)
 {
     $mailer = new JPhpMailer(true);
     // $mailer->SingleTo = true;
     try {
         $mailer->Subject = 'Rags Blind Draw Password Reset';
         $mailer->SetFrom('*****@*****.**');
         $mailer->AddReplyTo('*****@*****.**');
         $mailer->MsgHTML($controller->renderPartial('password_reset_email', array('uuid' => $uuid), true));
         $mailer->AddAddress($this->email, $user->f_name . ' ' . $user->l_name);
         $mailer->send();
     } catch (phpmailerException $e) {
         $error = $e->errorMessage();
     } catch (Exception $e) {
         $error = $e->getMessage();
     }
     if ($error) {
         Yii::app()->user->setFlash('error', $error);
         return false;
     }
     Yii::app()->user->setFlash('success', 'Please check your email and follow the link to reset your password');
     return true;
 }
Example #21
0
 public static function sendEmail($senderDetails, $receiverDetails, $subject, $message)
 {
     Yii::import('application.extensions.phpmailer.JPhpMailer');
     $mail = new JPhpMailer();
     $mail->IsSMTP();
     //$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
     $mail->Host = Yii::app()->params['mailHost'];
     // using google smtp
     $mail->Port = 465;
     // or 587/465
     $mail->SMTPAuth = true;
     $mail->SMTPSecure = "ssl";
     //only gor gmail
     $mail->Username = Yii::app()->params['adminEmail'];
     //host login name or email
     $mail->Password = Yii::app()->params['hostPassword'];
     $mail->SetFrom($senderDetails['email'], $senderDetails['name']);
     $mail->Subject = $subject;
     //$mail->AltBody = $message;
     $mail->Body = $message;
     $mail->MsgHTML($message);
     $mail->AddAddress($receiverDetails['email'], $receiverDetails['name']);
     return $mail->Send();
 }
Example #22
0
 public function actionSendTestMail()
 {
     if (Yii::app()->request->isAjaxRequest) {
         $host = trim(Yii::app()->request->getPost('host'));
         $username = trim(Yii::app()->request->getPost('username'));
         $password = trim(Yii::app()->request->getPost('password'));
         $from = trim(Yii::app()->request->getPost('from'));
         $recipient = trim(Yii::app()->request->getPost('recipient'));
         Yii::import('application.extensions.phpmailer.JPhpMailer');
         try {
             $mail = new JPhpMailer(true);
             $mail->SetLanguage('zh_cn');
             $mail->CharSet = 'UTF-8';
             $mail->IsSMTP();
             $mail->Host = $host;
             $mail->SMTPAuth = true;
             $mail->Username = $username;
             $mail->Password = $password;
             $mail->SetFrom($from);
             $mail->Subject = 'Test Subject';
             $mail->MsgHTML('Test Content');
             $mail->AddAddress($recipient);
             if ($mail->Send()) {
                 echo CJSON::encode(array('result' => true));
             } else {
                 throw new CException($mail->ErrorInfo);
             }
         } catch (Exception $e) {
             echo CJSON::encode(array('result' => false, 'message' => $e->getMessage()));
         }
     }
     Yii::app()->end();
 }
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     // thu vien mail
     Yii::import('application.extensions.phpmailer.JPhpMailer');
     // check login
     if (!empty(Yii::app()->user->id)) {
         $this->redirect(Yii::app()->createurl(''));
     }
     $page = 0;
     $status = '';
     $sended = '';
     if (!empty($_REQUEST['username']) && !empty($_REQUEST['email'])) {
         $username_var = trim($_REQUEST['username']);
         $username_var = str_replace(array(',', "'", '"', ' ', '%'), '', $username_var);
         $email_var = trim($_REQUEST['email']);
         $email_var = str_replace(array(',', "'", '"', ' ', '%'), '', $email_var);
         //check user
         $criteria = new CDbCriteria();
         $criteria->select = array('*');
         $criteria->addCondition('username= "******"');
         $data = WUser::model()->find($criteria);
         $data = CJSON::decode(CJSON::encode($data));
         // var_dump($data);
         // end check user
         if (empty($data)) {
             $status = 'Tài Khoản Không Tồn Tại !';
         } else {
             if ($data['email'] != $email_var) {
                 $status = 'Không đúng emai đăng ký !';
             }
         }
         if (empty($status)) {
             // save data
             $token_string = md5(trim($_REQUEST['username'] . $_REQUEST['email']));
             $url_token_string = $_SERVER['HTTP_HOST'] . Yii::app()->createurl('WUserLosePass/Rspass&acc=' . $username_var . '&token=' . $token_string);
             $date_now = date('Y-m-d');
             $date_now = strtotime($date_now);
             $date_end = strtotime("+1 day", $date_now);
             $date_end = date('Y-m-d', $date_end);
             // echo $date_now;
             // xoa lost cu
             $criteria = new CDbCriteria();
             $criteria->select = array('*');
             $criteria->addCondition('user_name= "' . $username_var . '"');
             $get_lost_id = WUserLosePass::model()->findAll($criteria);
             $get_lost_id = CJSON::decode(CJSON::encode($get_lost_id));
             if ($get_lost_id) {
                 foreach ($get_lost_id as $key => $value) {
                     $id = $value['id'];
                     $this->loadModel($id)->delete();
                 }
             }
             // them moi
             $model = new WUserLosePass();
             $model->user_name = $_REQUEST['username'];
             $model->token_check = $token_string;
             $model->end_time_change = $date_end;
             if ($model->save()) {
                 // end save data
                 // send mail
                 $mail = new JPhpMailer();
             }
             $mail->charset = "UTF-8";
             $mail->IsSMTP();
             $mail->Host = 'smtp.gmail.com';
             $mail->Port = 587;
             $mail->SMTPSecure = 'tls';
             $mail->SMTPAuth = true;
             $mail->Username = '******';
             $mail->Password = '******';
             $mail->SetFrom('*****@*****.**', 'Level account password People Link !');
             $mail->Subject = 'Level account password People Link !';
             $mail->AltBody = '';
             $header = '<h1>Xác nhận cấp lại mật khẩu !</h1>';
             $footer = '<p></p>';
             $body = '<p>nhấp vào link phía dười để xác nhận reset mật khẩu , link chỉ sử dụng được 1 lần !</p>';
             $body .= '<a href="' . $url_token_string . '">' . $url_token_string . '</a>';
             $mail->MsgHTML($header . $body . $footer);
             $mail->AddAddress($email_var);
             // $mail->SMTPDebug = 2;
             if (!$mail->Send()) {
                 // print_r($mail->ErrorInfo);
             }
             $status = 'Bạn vui lòng kiểm tra Email để xác thực tài khoản !';
             $page = 1;
             $this->render('sendmail');
             // end sned mail
         }
     }
     if ($page == 0) {
         $dataProvider = new CActiveDataProvider('WUserLosePass');
         $this->render('index', array('dataProvider' => $dataProvider, 'status' => $status, 'sended' => $sended));
     }
 }
Example #24
0
 public function actionNotify($id)
 {
     $model = $this->loadModel($id);
     $accountant = User::model()->find('role = 10');
     $message = '<p>' . $accountant->name . ',</p>';
     $message .= '<p>Необходимо проставить номер счета в одном из счетов в AdMoney<p>';
     $message .= '<p>Пожалуйста, <a href="http://admoney.localhost/payment/update/' . $id . '">пройдите по ссылке</a></p>';
     Yii::import('application.extensions.phpmailer.JPhpMailer');
     $mail = new JPhpMailer();
     $mail->IsSMTP();
     $mail->Host = 'mail.morizo.ru';
     $mail->SMTPAuth = true;
     $mail->Username = '******';
     $mail->Password = '******';
     $mail->SetFrom('*****@*****.**', 'AdMoney');
     $mail->Subject = 'Запрос номера счета из AdMoney';
     $mail->CharSet = 'UTF-8';
     $mail->AltBody = 'Для просмотра сообщения нужно включить режим HTML';
     $mail->MsgHTML($message);
     $mail->AddAddress($accountant->email, $accountant->name);
     $mail->Send();
     $this->render('notify');
 }
Example #25
0
 public static function sentEmail($setFromEmail, $setFromName, $emailDestination, $nameDestination, $subject, $msg, $category = 0, $cc = null, $attachment = null)
 {
     /*
     	list category
     	0=common, 1=registration, 2=vacancy, 3=test_call, 4=message, 5=finance
     */
     Yii::import('ext.jphpmailer.JPhpMailer');
     Yii::import('application.modules.email.models.CcnSendEmailLog');
     $mail = new JPhpMailer();
     //log email into database
     $emailLog = new CcnSendEmailLog();
     $emailLog->category = $category;
     $emailLog->date_inserted = date('Y-m-d H:i:s');
     $emailLog->date_sent = date('Y-m-d H:i:s');
     $emailLog->header_from = $setFromEmail;
     $emailLog->email_to = $emailDestination;
     $emailLog->subject = $subject;
     $emailLog->msg = $msg;
     if ($_SERVER["HTTP_HOST"] == 'localhost' || $_SERVER['SERVER_ADDR'] == '192.168.1.250') {
         //in localhost or testing condition
         //smtp google
         $mail->IsSMTP();
         $mail->SMTPSecure = "ssl";
         $mail->SMTPAuth = true;
         // enable SMTP authentication
         $mail->Host = "smtp.gmail.com";
         // sets the SMTP server
         $mail->Port = 465;
         // set the SMTP port for the GMAIL server
         $mail->Username = "******";
         // SMTP account username
         $mail->Password = "******";
         $mail->SetFrom($setFromEmail, $setFromName);
         $mail->Subject = $subject;
         $mail->MsgHTML($msg);
         //$options  = WebOption::model()->findByPk(1);
         //$emailDestination = $options->email_testing;
         $mail->AddAddress($emailDestination, $nameDestination);
         if ($cc != null && count($cc) > 0) {
             foreach ($cc as $to => $name) {
                 $mail->AddAddress($to, $name);
             }
         }
         if ($attachment != null) {
             $mail->addAttachment($attachment);
         }
     } else {
         //live server
         $mail->IsMail();
         $mail->SetFrom($setFromEmail, $setFromName);
         $mail->Subject = $subject;
         $mail->MsgHTML($msg);
         $mail->AddAddress($emailDestination, $nameDestination);
         $mail->AddReplyTo($setFromEmail, $setFromName);
         if ($attachment != null) {
             $mail->addAttachment($attachment);
         }
         if ($cc != null && count($cc) > 0) {
             foreach ($cc as $to => $name) {
                 $mail->AddAddress($to, $name);
             }
         }
     }
     //	file_put_contents('assets/cek_email.html', $msg);
     if ($_SERVER["HTTP_HOST"] == 'localhost') {
         $emailLog->is_sended = 1;
         $emailLog->save();
         $file = fopen('assets/localhost_email_' . $emailDestination . '.html', 'w+');
         fwrite($file, $msg);
         fclose($file);
         return true;
     } else {
         if ($mail->Send()) {
             $emailLog->is_sended = 1;
             $emailLog->save();
             return true;
         } else {
             $emailLog->is_sended = 0;
             $emailLog->save();
             return false;
         }
     }
 }
 /**
  * Sent Email
  */
 public static function sendEmail($to_email, $to_name, $subject, $message, $type, $cc = null, $attachment = null)
 {
     ini_set('max_execution_time', 0);
     ob_start();
     Yii::import('application.extensions.phpmailer.JPhpMailer');
     $model = self::model()->findByPk(1, array('select' => 'mail_contact, mail_name, mail_from, mail_smtp, smtp_address, smtp_port, smtp_username, smtp_password, smtp_ssl'));
     $mail = new JPhpMailer();
     if ($model->mail_smtp == 1 || $_SERVER["SERVER_ADDR"] == '127.0.0.1' || $_SERVER["HTTP_HOST"] == 'localhost') {
         //in localhost or testing condition
         //smtp google
         $mail->IsSMTP();
         // Set mailer to use SMTP
         $mail->Host = $model->smtp_address;
         // Specify main and backup server
         $mail->Port = $model->smtp_port;
         // set the SMTP port
         $mail->SMTPAuth = true;
         // Enable SMTP authentication
         $mail->Username = $model->smtp_username;
         // SES SMTP  username
         $mail->Password = $model->smtp_password;
         // SES SMTP password
         if ($model->smtp_ssl != 0) {
             $mail->SMTPSecure = $model->smtp_ssl == 1 ? "tls" : "ssl";
         }
         // Enable encryption, 'ssl' also accepted
     } else {
         //live server
         $mail->IsMail();
     }
     /**
      * 0 = to admin
      * 1 = to user
      */
     if ($type == 0) {
         $mail->SetFrom($to_email, $to_name);
         $mail->AddReplyTo($to_email, $to_name);
         $mail->AddAddress($model->mail_contact, $model->mail_name);
     } else {
         $mail->SetFrom($model->mail_from, $model->mail_name);
         $mail->AddReplyTo($model->mail_from, $model->mail_name);
         $mail->AddAddress($to_email, $to_name);
     }
     // cc
     if ($cc != null && count($cc) > 0) {
         foreach ($cc as $email => $name) {
             $mail->AddAddress($email, $name);
         }
     }
     // attachment
     if ($attachment != null) {
         $mail->addAttachment($attachment);
     }
     $mail->Subject = $subject;
     $mail->MsgHTML($message);
     if ($mail->Send()) {
         return true;
         //echo 'send';
     } else {
         return false;
         //echo 'no send';
     }
     ob_end_flush();
 }
 public function actionIndex()
 {
     $model = new TransaksiRegistrasi();
     $model_user = new Users();
     if (isset($_POST['TransaksiRegistrasi'])) {
         // 	if($model->validate() && $model_user->validate()){
         // 	echo "oke";
         // }else{
         // 	echo "ga oke";
         // }
         // die();
         $model->attributes = $_POST['TransaksiRegistrasi'];
         $cek = $model->validate();
         if ($cek) {
             // if($model->save()){
             $number = '';
             for ($i = 0; $i < 16; $i++) {
                 $number .= rand(0, 9);
             }
             $model->ID_FANBASE = 1;
             // $model->NO_SAKTI = $number;
             $model->VAD = $this->randomNumber(16);
             $model->STATUS_REKONSILIASI = 0;
             $model->STATUS_RELEASE = 0;
             $tgl = explode('/', $_POST['TransaksiRegistrasi']['TANGGAL']);
             $model->TANGGAL = $tgl[2] . '-' . $tgl[0] . '-' . $tgl[1];
             $model->VALIDASI_UPLOAD = 0;
             // print_r($model); die();
             $model->save(false);
             $model_user->ID_FANBASE = $model->ID_FANBASE;
             $model_user->ID_REGISTRASI = $model->ID_REGISTRASI;
             $model_user->ID_JENIS = 4;
             $model_user->VAS = '-';
             $model_user->STATUS = 0;
             $model_user->save(false);
             Yii::import('application.extensions.phpmailer.JPhpMailer');
             $mail = new JPhpMailer();
             $mail->isSMTP();
             $mail->Debugoutput = 'html';
             $mail->Host = 'smtp.gmail.com';
             $mail->Port = 587;
             $mail->SMTPSecure = 'tls';
             $mail->SMTPAuth = true;
             $mail->Username = "******";
             $mail->Password = "******";
             $mail->setFrom('*****@*****.**', 'Admin Soniq');
             // $mail->addReplyTo('*****@*****.**', 'First Last');
             $mail->addAddress($model->EMAIL, $model->NAMA_LENGKAP);
             $mail->Subject = 'Konfirmasi Registrasi Soniq';
             $mail->MsgHTML('<h1> Hello, ' . $model->NAMA_LENGKAP . '</h1><br> Virtual ID anda : <b>' . $model->VAD . '</b>');
             // $mail->Body    = '';
             // $mail->AltBody = 'This is a plain-text message body';
             //Attach an image file
             //$mail->addAttachment('images/phpmailer_mini.png');
             //send the message, check for errors
             // if (!$mail->send()) {
             // 	$res = "Email Gagal Dikirim";
             // }else {
             // 	$res = "Email Sudah Dikirm";
             // }
             $res = 'kirim email di matikan';
             Yii::app()->user->setFlash('Virtual ID', $model->VAD);
             Yii::app()->user->setFlash('Email', $model->EMAIL);
             Yii::app()->user->setFlash('Status', $res);
             // $data = array('vad'=>$model->VAD,'pwd'=>$model_user->PASSWORD,'email'=>$model->EMAIL);
             $this->redirect(array('confirm'));
         }
     }
     $this->render('create', array('model' => $model, 'model_user' => $model_user));
 }
Example #28
0
//permite modo debug para ver mensajes de las cosas que van ocurriendo
    $mail->SMTPDebug  = 2;
//Debo de hacer autenticación SMTP
    $mail->SMTPAuth = true;
     $mail->SMTPSecure  = "ssl";
//indico el servidor de Gmail para SMTP
    $mail->Host= "smtp.gmail.com";
//indico el puerto que usa Gmail
    $mail->Port = 465;
//indico un usuario / clave de un usuario de gmail
    $mail->Username = "******";
    $mail->Password = "******";
    $mail->SetFrom('*****@*****.**', 'Julian ramirez');
    $mail->AddReplyTo("*****@*****.**","Julian ramirez");
    $mail->Subject = "Envío de email usando SMTP de Gmail";
    $mail->MsgHTML("Hola que tal, esto es el cuerpo del mensaje!");
//indico destinatario
    $address = "*****@*****.**";
    $mail->AddAddress($address, "Nombre completo");
    if(! $mail->Send()) {
        echo "Error al enviar: " .  $mail->ErrorInfo;
    } else {
        echo "Mensaje enviado!";
    }
 */
 public static function send($to, $subject = null, $body = null, $header = null)
 {
     if ($to instanceof YumUser) {
         $to = $to->profile->email;
     }
     if (!is_array($to)) {
         $to = array('to' => $to, 'subject' => $subject, 'body' => $body);
     }
     if (Yum::module()->mailer == 'swift') {
         $sm = Yii::app()->swiftMailer;
         $mailer = $sm->mailer($sm->mailTransport());
         $message = $sm->newMessage($to['subject'])->setFrom($to['from'])->setTo($to['to'])->setBody($to['body']);
         return $mailer->send($message);
     } else {
         if (Yum::module()->mailer == 'PHPMailer') {
             Yii::import('application.extensions.phpmailer.JPhpMailer');
             $mailer = new JPhpMailer(true);
             if (Yum::module()->phpmailer['transport']) {
                 switch (Yum::module()->phpmailer['transport']) {
                     case 'smtp':
                         $mailer->IsSMTP();
                         break;
                     case 'sendmail':
                         $mailer->IsSendmail();
                         break;
                     case 'qmail':
                         $mailer->IsQmail();
                         break;
                     case 'mail':
                     default:
                         $mailer->IsMail();
                 }
             } else {
                 $mailer->IsMail();
             }
             if (Yum::module()->phpmailer['html']) {
                 $mailer->IsHTML(Yum::module()->phpmailer['html']);
             } else {
                 $mailer->IsHTML(false);
             }
             $mailerconf = Yum::module()->phpmailer['properties'];
             if (is_array($mailerconf)) {
                 foreach ($mailerconf as $key => $value) {
                     if (isset(JPhpMailer::${$key})) {
                         JPhpMailer::${$key} = $value;
                     } else {
                         $mailer->{$key} = $value;
                     }
                 }
             }
             $mailer->SetFrom($to['from'], Yum::module()->phpmailer['msgOptions']['fromName']);
             //FIXME
             $mailer->AddAddress($to['to'], Yum::module()->phpmailer['msgOptions']['toName']);
             //FIXME
             $mailer->Subject = $to['subject'];
             $mailer->Body = $to['body'];
             return $mailer->Send();
         } else {
             if ($header == null) {
                 $header = 'MIME-Version: 1.0' . "\r\n";
                 $header .= 'Content-type: text/html; charset=utf-8' . "\r\n";
                 $header .= 'From: ' . Yum::module('message')->adminEmail . "\r\n";
                 $header .= 'To: ' . $to['to'] . "\r\n";
             }
             return mail($to['to'], $to['subject'], $to['body'], $header);
         }
     }
 }
Example #30
0
 public static function sendMail($sender, $senderPass, $toaddress, $subject, $content, $u, $attachs = null)
 {
     $mail = new JPhpMailer();
     $mail->SMTPDebug = 1;
     $mail->IsSMTP();
     $mail->Host = 'Smtpcom.263xmail.com';
     $mail->SMTPAuth = true;
     $mail->CharSet = "UTF-8";
     // 设置字符集编码
     $mail->Username = $sender;
     $mail->Password = $senderPass;
     $mail->AddAddress($toaddress, '=?UTF-8?B?' . '?=');
     // [{"url":"\/uploads\/email\/files\/1427626820-fb57060ef2463c124b894351630a4840.gif","type":"gif","name":"%}_BE}A14T2D@HBIG6}IRF4"},{"url":"\/uploads\/email\/files\/1427626820-fb57060ef2463c124b894351630a4840.gif1427626820-195715f9d4dd77b06beab61a8500b2c9.gif","type":"gif","name":"%1@X07Y86M0I25B4F9]04$B"},{"url":"\/uploads\/email\/files\/1427626820-fb57060ef2463c124b894351630a4840.gif1427626820-195715f9d4dd77b06beab61a8500b2c9.gif1427626820-fe15e4b517b0475e280cf60ea11b5bd8.gif","type":"gif","name":"%5K@8]W2XCU@{_)[M6]H{DB"}]
     if ($attachs) {
         $attachs = json_decode($attachs);
         foreach ($attachs as $attach) {
             $mail->AddAttachment(Yii::getPathOfAlias('webroot') . $attach->url, $attach->name . '.' . $attach->type);
         }
     }
     $mail->IsHTML(true);
     // send as HTML
     $mail->SetFrom($sender, '=?UTF-8?B?' . base64_encode($u->username) . '?=');
     $mail->Subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
     $mail->AltBody = 'Please switch to HTML mode to view the email';
     $content = self::embed_images($mail, $content);
     $mail->MsgHTML($content);
     $mail->Send();
 }