public function __construct()
{
$views = MW_PATH . 'Views' . DS;
View::addNamespace('mw_email_send', $views);
$email_from = mw()->option_manager->get('email_from_name', 'email');
if ($email_from == false or trim($email_from) == '') {
$email_from = getenv('USERNAME');
}
$this->email_from_name = $email_from;
$this->smtp_host = trim(mw()->option_manager->get('smtp_host', 'email'));
$this->smtp_port = intval(mw()->option_manager->get('smtp_port', 'email'));
$this->smtp_username = trim(mw()->option_manager->get('smtp_username', 'email'));
$this->smtp_password = trim(mw()->option_manager->get('smtp_password', 'email'));
$this->smtp_auth = trim(mw()->option_manager->get('smtp_auth', 'email'));
$this->transport = trim(mw()->option_manager->get('email_transport', 'email'));
$sec = mw()->option_manager->get('smtp_secure', 'email');
$this->smtp_secure = intval($sec);
$email_from = mw()->option_manager->get('email_from', 'email');
if ($email_from == false or trim($email_from) == '') {
if ($this->email_from_name != '') {
$email_from = $this->email_from_name . '@' . mw()->url_manager->hostname();
} else {
$email_from = 'noreply@' . mw()->url_manager->hostname();
}
$email_from = str_replace(' ', '-', $email_from);
}
$this->email_from = $email_from;
$this->here = dirname(__FILE__);
Config::set('mail.from.name', $this->email_from_name);
Config::set('mail.from.address', $this->email_from);
Config::set('mail.username', $this->smtp_username);
Config::set('mail.password', $this->smtp_password);
if ($this->transport == '' or $this->transport == 'php') {
Config::set('mail.driver', 'mail');
}
if ($this->transport == 'gmail') {
Config::set('mail.host', 'smtp.gmail.com');
Config::set('mail.port', 587);
Config::set('mail.encryption', 'tls');
} else {
Config::set('mail.host', $this->smtp_host);
Config::set('mail.port', $this->smtp_port);
Config::set('mail.encryption', $this->smtp_auth);
}
}