method __construct documentation in bbn\Mail

Constructor.

function($cfg = []) { if ( !\defined('BBN_ADMIN_EMAIL') || !\defined('BBN_IS_DEV') ){ die("You must provide the constants BBN_ADMIN_EMAIL and BBN_IS_DEV to use the mail class..."); } if ( !isset($cfg['from']) && isset($cfg['user']) ){ $cfg['from'] = $cfg['user']; } if (!isset($cfg['from'])) { $cfg['from'] = BBN_ADMIN_EMAIL; } if (!PHPMailer::validateAddress($cfg['from'])) { die(X::_("A \"From\" eMail address must be provided")); } $has_host = !empty($cfg['host']) && Str::isDomain($cfg['host']); $this->mailer = new PHPMailer(true); try { $this->mailer->CharSet = isset($cfg['charset']) ? $cfg['charset'] : "US-ASCII"; $this->mailer->Encoding = isset($cfg['encoding']) ? $cfg['encoding'] : "base64"; $this->mailer->AllowCharsetEncoding = false; if ( isset($cfg['user'], $cfg['pass']) ){ // SMTP connection will not close after each email sent, reduces SMTP overhead $this->mailer->isSMTP(); if ( !empty($cfg['ssl']) ){ if ( \is_array($cfg['ssl']) ){ $this->mailer->SMTPOptions = ['ssl' => $cfg['ssl']]; } else{ $this->mailer->SMTPOptions = [ 'verify_peer' => false, 'verify_peer_name' => false, 'verify_host' => false, 'allow_self_signed' => false ]; } } else{ $this->mailer->SMTPSecure = 'tls'; } $this->mailer->Host = $has_host ? $cfg['host'] : 'localhost'; $this->mailer->Port = isset($cfg['port']) ? $cfg['port'] : 587; $this->mailer->SMTPKeepAlive = true; $this->mailer->SMTPDebug = empty($cfg['debug']) ? false : 3; $this->mailer->Debugoutput = 'error_log'; $this->mailer->SMTPAuth = true; $this->mailer->Username = $cfg['user']; $this->mailer->Password = $cfg['pass']; if ( !empty($cfg['imap']) ){ $this->setImap($cfg); } } $this->setFrom($cfg['from'], isset($cfg['name']) ? $cfg['name'] : 0); $this->setTemplate(isset($cfg['template']) ? $cfg['template'] : self::getDefaultTemplate()); } catch (\Exception $e) { $this->log($this->mailer->ErrorInfo); } }

Constructor. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.