/** * Sendet die Message * * Wird Transport und Mailer nicht angegeben, werden diese erstellt * Ist ein Mailer angegeben wird transport nicht erstellt (wird ignoriert) * * wenn ein SMTP Zugang mit Config[mail.smtp.user] und Config[mail.smtp.password] gesetzt wurde, * wird dieser als Transport genutzt ansonsten der lokale Mailer * @return die Ausgabe von mailer->send() (int $sent) */ public static function send(Swift_Message $message, Swift_SmtpTransport $transport = NULL, Swift_Mailer $mailer = NULL) { if (!isset($transport) && !isset($mailer)) { if (Config::req('mail.smtp.user') != NULL) { $transport = Swift_SmtpTransport::newInstance('smtprelaypool.ispgateway.de', 465, 'ssl')->setUsername(Config::req('mail.smtp.user'))->setPassword(Config::req('mail.smtp.password')); } else { $transport = Swift_Mailtransport::newInstance(); // lokaler mailer } } if (!isset($mailer)) { $mailer = \Swift_Mailer::newInstance($transport); } return $mailer->send($message); }
public function init() { if (!isset($this->recipient)) { $this->recipient = $this->config->req('ContactForm.recipient'); } if (!isset($this->template)) { throw new \Psc\Exception('Mailtemplate muss gesetzt sein. Sonst ist die Mail leer'); } if (!isset($this->subject)) { throw new \Psc\Exception('Subject muss gesetzt sein.'); } if ($this->mode === self::MODE_SMTP) { $this->transport = \Swift_SmtpTransport::newInstance('smtprelaypool.ispgateway.de', 465, 'ssl')->setUsername($this->config->req('mail.smtp.user'))->setPassword($this->config->req('mail.smtp.password')); $this->mailer = Swift_Mailer::newInstance($this->transport); } elseif ($this->mode === self::MODE_NULL) { $this->transport = Swift_NullTransport::newInstance(); $this->mailer = Swift_Mailer::newInstance($this->transport); $this->logger = new Swift_Plugins_Loggers_ArrayLogger(); $this->mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($this->logger)); } elseif ($this->mode === self::MODE_LOCAL_MAIL) { $this->transport = Swift_Mailtransport::newInstance(); $this->mailer = Swift_Mailer::newInstance($this->transport); } else { throw new RuntimeException('Mode is set to wrong constant' . Code::varInfo($this->mode)); } $this->init = TRUE; }