/**
  * @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);
 }