protected function set_send_settings(PHPMailer $mailer) { $mailer->IsSMTP(); $mailer->SMTPDebug = 1; $mailer->SMTPAuth = true; $mailer->Timeout = 1; $auth_mode = $this->configuration->get_auth_mode(); if (!empty($auth_mode)) { $mailer->SMTPSecure = $this->configuration->get_auth_mode(); } $mailer->Host = $this->configuration->get_host(); $mailer->Port = $this->configuration->get_port(); $mailer->Username = $this->configuration->get_login(); $mailer->Password = $this->configuration->get_password(); }
/** * @return SMTPConfiguration */ public function to_smtp_config() { if ($this->is_smtp_enabled()) { $config = new SMTPConfiguration(); $config->set_host($this->get_smtp_host()); $config->set_port($this->get_smtp_port()); $config->set_login($this->get_smtp_login()); $config->set_password($this->get_smtp_password()); $config->set_auth_mode($this->get_smtp_protocol()); return $config; } else { return null; } }
private function send_mail() { if ($this->form->get_value('use_smtp')) { $configuration = new SMTPConfiguration(); $configuration->set_host($this->form->get_value('smtp_host')); $configuration->set_port($this->form->get_value('smtp_port')); $configuration->set_login($this->form->get_value('smtp_login')); $configuration->set_password($this->form->get_value('smtp_password')); $configuration->set_auth_mode($this->form->get_value('secure_protocol')->get_raw_value()); $mailer = new SMTPMailService($configuration); } else { $mailer = new DefaultMailService(); } $mail = new Mail(); $mail->add_recipient($this->form->get_value('recipient_mail'), $this->form->get_value('recipient_name')); $mail->set_sender($this->form->get_value('sender_mail'), $this->form->get_value('sender_name')); $mail->set_subject($this->form->get_value('mail_subject')); $mail->set_content($this->form->get_value('mail_content')); return $mailer->send($mail); }