コード例 #1
0
ファイル: MyPhpMailer.php プロジェクト: postfx/fermion
 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;
     }
 }
コード例 #2
0
ファイル: Controller.php プロジェクト: robertgunze/eams
 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();
 }
コード例 #3
0
 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é';
     }
 }
コード例 #4
0
ファイル: CronjobCommand.php プロジェクト: jencina/checklist
 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();
     //}
 }
コード例 #5
0
ファイル: TTMailer.php プロジェクト: schrapps/risksur
 /**
  * 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;
 }
コード例 #6
0
 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();
 }
コード例 #7
0
 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();
 }
コード例 #8
0
 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();
 }
コード例 #9
0
 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()) {
     }
 }
コード例 #10
0
ファイル: index.php プロジェクト: nmalservet/biocap
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;
    }
}
コード例 #11
0
ファイル: HMailHelper.php プロジェクト: qkongvan/k6-thuc-pham
 /**
  * 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();
 }
コード例 #12
0
 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;
 }
コード例 #13
0
ファイル: Notification.php プロジェクト: robertgunze/eams
 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();
 }
コード例 #14
0
 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));
 }
コード例 #15
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();
 }
コード例 #16
0
 /**
  * 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));
     }
 }
コード例 #17
0
ファイル: MiClaseCrugeMailer.php プロジェクト: hipogea/zega
//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!";
    }
 */
コード例 #18
0
ファイル: PaymentController.php プロジェクト: GKillah/social
 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');
 }
コード例 #19
0
 /**
  * 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();
 }
コード例 #20
0
ファイル: Utility.php プロジェクト: alfinresa/demo
 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;
         }
     }
 }
コード例 #21
0
ファイル: Tools.php プロジェクト: djspys1/baoku
 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();
 }
コード例 #22
0
ファイル: CiiController.php プロジェクト: fandikurnia/CiiMS
 /**
  * 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;
 }
コード例 #23
0
 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);
         }
     }
 }
コード例 #24
0
ファイル: Controller.php プロジェクト: bhaiyyalal/testcode
 function SendMail($to, $to_name, $subject, $message)
 {
     Yii::import('application.extensions.phpmailer.JPhpMailer');
     $mail = new JPhpMailer();
     $mail->IsSMTP();
     $mail->Host = $this->Host;
     $mail->SMTPSecure = "ssl";
     $mail->SMTPAuth = true;
     $mail->Username = $this->Username;
     $mail->Password = $this->user_password;
     $mail->SetFrom($this->from_smtp, $this->site_name);
     $mail->Subject = $subject;
     $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
     $mail->MsgHTML($message);
     $mail->AddAddress($to, $to_name);
     if ($mail->Send()) {
         return true;
     } else {
         return false;
     }
 }