Ejemplo n.º 1
0
 /**
  * Sends mail using SMTP.
  * @param string $from User's email address
  * @param string $subject Subject of the email
  * @param string $body Body of the email
  * @param boolean $html true indicates that the body format is html; false means the body is plain text
  * @return true|false
  */
 private function sendMailSmtp($from, $fromName, $subject, $body, $html = false)
 {
     $mailParams = array('from' => $from, 'fromName' => $fromName, 'to' => Yii::app()->params['adminEmail'], 'subject' => $subject, 'body' => $body);
     return MailSender::sendSMTP($mailParams, '', 'text/plain');
 }
Ejemplo n.º 2
0
 public static function sendRegisterVerification($email, $username)
 {
     if (empty($email)) {
         return false;
     }
     $key = sha1(uniqid(rand()));
     $data = array('verification_key' => $key);
     $model = EmailVerification::model()->get($email);
     if ($model === null) {
         /*$model = new EmailVerification();
         		$model->email = $email;
         		$model->verification_key = $key;*/
         $mailParams = array('from' => Yii::app()->params['adminEmail'], 'fromName' => 'LintinZone', 'to' => $email, 'subject' => 'LintinZone ' . UserModule::t('Xác nhận đăng ký thành viên'), 'body' => array('{receiver}' => empty($username) ? UserModule::t('my friend') : $username, '{confirm_link}' => Yii::app()->createAbsoluteUrl('user/registration/confirm', array('key' => $key, 'email' => $email)), '{support_link}' => Yii::app()->createAbsoluteUrl('site/contact', array('email' => $email)), '{home_link}' => Yii::app()->createAbsoluteUrl('')));
         if (MailSender::sendSMTP($mailParams, 'register', 'text/html')) {
             /*$model->sent_date = new CDbExpression('NOW()');
             		$model->save();*/
             $data['sent'] = true;
             $data['active'] = true;
             $data['verified'] = false;
             EmailVerification::model()->insert($email, $data);
             return true;
         }
         //$model->save();
         $data['sent'] = false;
         $data['active'] = true;
         $data['verified'] = false;
         EmailVerification::model()->insert($email, $data);
         return false;
     } else {
         if (!$model->verified) {
             //$model->verification_key = $key;
             $mailParams = array('from' => Yii::app()->params['adminEmail'], 'fromName' => 'LintinZone', 'to' => $email, 'subject' => 'LintinZone ' . UserModule::t('Xác nhận đăng ký thành viên'), 'body' => array('{receiver}' => empty($username) ? UserModule::t('my friend') : $username, '{confirm_link}' => Yii::app()->createAbsoluteUrl('user/registration/confirm', array('key' => $key, 'email' => $email)), '{support_link}' => Yii::app()->createAbsoluteUrl('site/contact', array('email' => $email)), '{home_link}' => Yii::app()->createAbsoluteUrl('')));
             if (MailSender::sendSMTP($mailParams, 'register', 'text/html')) {
                 $data['sent'] = true;
                 $data['active'] = true;
                 $data['verified'] = false;
                 EmailVerification::model()->insert($email, $data);
                 return true;
             }
             $data['sent'] = false;
             $data['active'] = true;
             $data['verified'] = false;
             EmailVerification::model()->insert($email, $data);
             return false;
         } else {
             return true;
         }
     }
 }