public function send() { //Yii::import('application.extensions.smtpmail.PHPMailer'); $mailer = new \yii\swiftmailer\Mailer(["transport" => ['class' => 'Swift_SmtpTransport', 'host' => \app\helpers\Linet3Helper::getSetting('company.mail.server'), 'username' => \app\helpers\Linet3Helper::getSetting('company.mail.user'), 'password' => \app\helpers\Linet3Helper::getSetting('company.mail.password'), 'port' => \app\helpers\Linet3Helper::getSetting('company.mail.port'), 'encryption' => \app\helpers\Linet3Helper::getSetting('company.mail.ssl') ? 'tls' : '']]); $mail = $mailer->compose('layouts/html', ['content' => $this->body]); //$mail->SetFrom($this->from); //echo $this->files; if ($this->files != '') { $file = Files::findOne($this->files); if ($file != null) { //echo $file->getFullPath().";;".$file->name; $mail->attach($file->getFullFilePath(), ["fileName" => $file->name]); } } $mail->setFrom(\app\helpers\Linet3Helper::getSetting('company.mail.address'))->setTo($this->to)->setSubject($this->subject); if ($this->cc != '') { $mail->setCc($this->cc); } if ($this->bcc != '') { $mail->setBcc($this->bcc); } //$mail->AddCC($this->cc); //.$this->cc //$mail->AddBcc($this->bcc); //$mail-> //$mail->setHtmlBody($this->body); //$mail; if (!$mail->send()) { //echo "Mailer Error: " . $mail->ErrorInfo; throw new Exception(Yii::t('app', "Mailer Error: ") . $mail->ErrorInfo . $mail->Username); } else { $this->sent++; $this->save(); if (!\app\helpers\Linet3Helper::isConsole()) { \Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Message sent!')); } //echo "Message sent!"; } //*/ //Yii::$app->end(); }
use yii\helpers\Html; use app\assets\AppAsset; use app\assets\PrintAsset; /* use yii\bootstrap\Nav; use yii\bootstrap\NavBar; use yii\widgets\Breadcrumbs; use app\assets\PrintAsset; use app\models\Menu; */ /* @var $this \yii\web\View */ /* @var $content string */ // if (!\app\helpers\Linet3Helper::isConsole()) { //$base=yii\helpers\BaseUrl::base(); PrintAsset::register($this); AppAsset::register($this); //$logopath = $base."/site/download/" . Linet3Helper::getSetting('company.logo'); } else { //console $this->registerCssFile(Yii::$app->params['url'] . "/css/print.css"); //Yii::$app->basePath. $this->registerCssFile(Yii::$app->params['url'] . "/css/site.css"); if (\Yii::$app->language == 'he_il') { $this->registerCssFile(Yii::$app->params['url'] . "/css/print-rtl.css"); $this->registerCssFile(Yii::$app->params['url'] . "/css/site-rtl.css"); } } $this->beginPage();
public static function getLogo() { if (!\app\helpers\Linet3Helper::isConsole()) { return \Yii::$app->urlManager->createAbsoluteUrl("/site/download/" . Linet3Helper::getSetting('company.logo')); //$base . ; } else { //console $download = \app\models\Download::findOne(["id" => Linet3Helper::getSetting('company.logo')]); $id = (int) $download->file_id; $logo = \app\models\Files::findOne($id); return $logo->getFullFilePath(); } }