/var/www/vhosts/nabawater/common/helpers
NameSizeModeActions
AccessRules.php120510644editdlrm
AuthHandler.php75560644editdlrm
Aws.php57620644editdlrm
ChunkHelper.php9590644editdlrm
Com.php224100644editdlrm
DateTimeHelper.php71550644editdlrm
FBHelper.php41120644editdlrm
FileUploadHelper.php43510644editdlrm
GeoHelper.php125350644editdlrm
GeoMetricHelper.php55140644editdlrm
IPay88Helper.php46420644editdlrm
JwtHelper.php36730644editdlrm
Mailer.php45350644editdlrm
MailerQueueHelper.php31710644editdlrm
ModelHelper.php25530644editdlrm
OneSignal.php73770644editdlrm
PaymentHelper.php57840644editdlrm
QrHelper.php24560644editdlrm
RabbitMQHelper.php24060644editdlrm
SmsGateway.php18620644editdlrm
StripeHelper.php33350644editdlrm
UploadHelper.php161640644editdlrm
Edit: /var/www/vhosts/nabawater/common/helpers/Mailer.php (4535B)
*/ class Mailer { /** * @var */ private $subject; /** * @var */ private $message; /** * @var string|array */ private $to; /** * @var string|array */ private $file_attach; /** * @var string|array */ private $cc; /** * @var */ private static $instance; /** * Mailer constructor. * @throws \yii\base\InvalidConfigException */ private function __construct() { # do configuration stuff if (Configuration::isSmtpEnabled() === false) { return; } /* @var $transport yii\swiftmailer\Mailer */ $transport = Yii::$app->getMailer(); $transport->setTransport([ 'class' => \Swift_SmtpTransport::class, 'host' => Configuration::get(Configuration::SMTP_HOST), 'username' => Configuration::get(Configuration::SMTP_USERNAME), 'password' => Configuration::get(Configuration::SMTP_PASSWORD), 'port' => Configuration::get(Configuration::SMTP_PORT), 'encryption' => Configuration::get(Configuration::SMTP_ENCRYPTION), ]); $transport->messageConfig = [ 'from' => [Configuration::get(Configuration::SMTP_USERNAME) => Configuration::get(Configuration::APP_NAME)], ]; } /** * @return Mailer * @throws \yii\base\InvalidConfigException */ public static function getInstance() { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; } /** * @param mixed $subject * @return $this */ public function setFile($file_attach) { $this->file_attach = $file_attach; return $this; } /** * @param bool $debug * @return bool * @throws InvalidConfigException */ public function send($debug = false) { if (!Configuration::get(Configuration::IS_SMTP_ENABLED)) { return 'Mail is disabled'; } if ($this->message === null || $this->to === null || $this->subject === null) { throw new InvalidConfigException('Invalid mail configuration'); } try { return Yii::$app->mailer->compose() ->setTo($this->to) ->setCc($this->cc) ->setSubject($this->subject) ->setHtmlBody($this->message) ->send(); } catch (\Swift_TransportException $Ste) { if ($debug) { return $Ste->getMessage(); } return 0; } } /** * @param bool $debug * @return bool * @throws InvalidConfigException */ public function sendWithFile($debug = false) { if (!Configuration::get(Configuration::IS_SMTP_ENABLED)) { return 'Mail is disabled'; } // if ($this->message === null || $this->to === null || $this->subject === null) { // throw new InvalidConfigException('Invalid mail configuration'); // } try { return Yii::$app->mailer->compose() ->setTo($this->to) ->setCc($this->cc) ->setSubject($this->subject) ->setHtmlBody($this->message) ->attach($this->file_attach) ->send(); } catch (\Swift_TransportException $Ste) { if ($debug) { return $Ste->getMessage(); } return 0; } } /** * @param mixed $message * @return $this */ public function setMessage($message) { $this->message = $message; return $this; } /** * @param mixed $subject * @return $this */ public function setSubject($subject) { $this->subject = $subject; return $this; } /** * @param array|string $to * @return $this */ public function setTo($to) { $this->to = $to; return $this; } /** * @param $to * @return $this */ public function setCc($to) { $this->cc = $to; return $this; } }