diff --git a/module/Mailer/Module.php b/module/Mailer/Module.php new file mode 100644 index 0000000..d4e37c9 --- /dev/null +++ b/module/Mailer/Module.php @@ -0,0 +1,24 @@ + array( + 'namespaces' => array( + __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, + ), + ), + ); + } +} diff --git a/module/Mailer/config/module.config.php b/module/Mailer/config/module.config.php new file mode 100644 index 0000000..34900b3 --- /dev/null +++ b/module/Mailer/config/module.config.php @@ -0,0 +1,8 @@ + array( + 'factories' => array( + 'Mailer\Config' => 'Mailer\ConfigFactory', + ), + ), +); \ No newline at end of file diff --git a/module/Mailer/src/Mailer/Config.php b/module/Mailer/src/Mailer/Config.php new file mode 100644 index 0000000..f6dc698 --- /dev/null +++ b/module/Mailer/src/Mailer/Config.php @@ -0,0 +1,60 @@ +config = $config; + } + + /** + * Configure Transport Mailer + * @return \Swift_Transport + */ + public function getTransportConfigure() + { + switch ($this->config['method']) { + case 'sendmail': + $tr = \Swift_SendmailTransport::newInstance(); + break; + case 'smtp': + $tr = \Swift_SmtpTransport::newInstance(); + if (array_key_exists('port', $this->config)) { + $tr->setPort($this->config['port']); + } + if (array_key_exists('host', $this->config)) { + $tr->setHost($this->config['host']); + } + if (array_key_exists('username', $this->config)) { + $tr->setUsername($this->config['username']); + } + if (array_key_exists('password', $this->config)) { + $tr->setPassword($this->config('password')); + } + if (array_key_exists('authmode', $this->config)) { + $tr->setAuthMode($mode); + } + break; + default: + $tr = \Swift_MailTransport::newInstance(); + break; + } + + return $tr; + } + + public function getMailFromKey(string $name) + { + + } +} \ No newline at end of file diff --git a/module/Mailer/src/Mailer/ConfigFactory.php b/module/Mailer/src/Mailer/ConfigFactory.php new file mode 100644 index 0000000..6dde00e --- /dev/null +++ b/module/Mailer/src/Mailer/ConfigFactory.php @@ -0,0 +1,22 @@ +getServiceLocator(); + $appConfig = $serviceLocator->get('config'); + + $config = array(); + if (array_key_exists('mailer', $appConfig)) { + $config = $appConfig['mailer']; + } + + return new Config($config); + } +}