frontend/models/forms/SupportForm.php
/**
     * Sends an email to the specified email address using the information collected by this model.
     *
     * @return boolean whether the email was sent
     */
Sends an email to the specified email address using the information collected by this model.
@return boolean whether the email was sent
Sends an email to the specified email address using the information collected by this model . @return boolean whether the email was sent
public function sendEmail()
    {
        $to = Preferences::getValueByKey("supportEmail_{$this->subject}", Preferences::getValueByKey('adminEmail'));
        if (Yii::$app->user->isGuest) {
            $User = null;
            $from_name = "{$this->name} <{$this->email}>";
            $reply_to_email = $this->email;
            $reply_to_name  = $this->name;
        } else {
            $User = Users::findIdentity(Yii::$app->user->getId());
            $from_name = "{$User->user_name} <{$User->user_email}>";
            $reply_to_email = $User->user_email;
            $reply_to_name  = $User->user_name;
        }
        $subject = self::getSubjectLabel($this->subject) . " from {$from_name}";
        $body = "Message from support form\n\n" .
            "Name: {$from_name}\n" .
            "Email: {$reply_to_email}\n" .
            "Subject: {$subject}\n" .
            "Message: \n\n" . $this->body . "\n";
        $ms = new MessagesStore();
        $ms->ms_data = $body;
        $ms->ms_type = MessagesStore::TYPE_SUPPORT;
        $ms->user_id = ($User) ? $User->user_id : null;
        $ms->save();
        return MailTemplatesStatic::sendByKey(MailTemplatesStatic::template_key_standardMailTpl, $to, [
            'from_name'      => $from_name,
            'reply_to_email' => $reply_to_email,
            'reply_to_name'  => $reply_to_name,
            'subject'        => $subject,
            'body'           => $this->body,
            'to_name'        => 'Support',
            'UserObject'     => $User,
        ]);
    }
public function sendEmail ( ) { $ to = Preferences :: getValueByKey ( " supportEmail_ { $ this -> subject } " , Preferences :: getValueByKey ( 'adminEmail' ) ) ; if ( Yii :: $ app -> user -> isGuest ) { $ User = null ; $ from_name = " { $ this -> name }  < { $ this -> email } > " ; $ reply_to_email = $ this -> email ; $ reply_to_name = $ this -> name ; } else { $ User = Users :: findIdentity ( Yii :: $ app -> user -> getId ( ) ) ; $ from_name = " { $ User -> user_name }  < { $ User -> user_email } > " ; $ reply_to_email = $ User -> user_email ; $ reply_to_name = $ User -> user_name ; } $ subject = self :: getSubjectLabel ( $ this -> subject ) . "  from  { $ from_name } " ; $ body = " Message from support form \n \n " . " Name:  { $ from_name } \n " . " Email:  { $ reply_to_email } \n " . " Subject:  { $ subject } \n " . " Message:  \n \n " . $ this -> body . " \n " ; $ ms = new MessagesStore ( ) ; $ ms -> ms_data = $ body ; $ ms -> ms_type = MessagesStore :: TYPE_SUPPORT ; $ ms -> user_id = ( $ User ) ? $ User -> user_id : null ; $ ms -> save ( ) ; return MailTemplatesStatic :: sendByKey ( MailTemplatesStatic :: template_key_standardMailTpl , $ to , [ 'from_name' => $ from_name , 'reply_to_email' => $ reply_to_email , 'reply_to_name' => $ reply_to_name , 'subject' => $ subject , 'body' => $ this -> body , 'to_name' => 'Support' , 'UserObject' => $ User , ] ) ; }
Sends an email to the specified email address using the information collected by this model.
Sends an email to the specified email address using the information collected by this model .
/** @var $tk \common\models\Tikets */ /** @var $user \common\models\Users */ /*
        if (Yii::$app->user->isGuest) {
            $tk = Tikets::findOne(['user_id' => 0, 'tiket_email' => $this->email]);
            if (!$tk) { $tk  = new Tikets(); }
            $tk->user_id     = 0;
            $tk->tiket_email = $this->email;
            $tk->tiket_name  = $this->name;
        } else {
            $user = Yii::$app->user->identity;
            //var_dump($user->user_email); exit;
            $tk  = new Tikets();
            $tk->user_id     = $user->getId();
            $tk->tiket_email = $user->user_email;
            $tk->tiket_name  = $user->user_name;

            $this->email = $user->user_email;
            $this->name  = $user->user_name;
        }

        $tk->tiket_theme     = $this->subject;
        $tk->tiket_count_new_admin += 1;
        $tk->tiket_count_new_user   = 0;
        if ($tk->save()) {
            $tkm = new TiketsMessages();
            $tkm->tiket_id = $tk->tiket_id;
            $tkm->message_text = $this->body;
            $tkm->user_id = $tk->user_id;
            $tkm->save();
        }
        */ //'from_email'     => 'support@pvtbox.net',