예제 #1
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);
    }
}
예제 #2
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();
 }
 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;
 }
예제 #4
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;
        }
    }