@@ -15,6 +15,12 @@ class SiteSettingDefinition extends AbstractSettingDefinition implements SiteSet | |||
const SETTING_EMAIL_FROM = 'emailFrom'; | |||
const SETTING_EMAIL_FROM_NAME = 'emailFromName'; | |||
const SETTING_MAILER_HOST = 'mailerHost'; | |||
const SETTING_MAILER_HOST_MAILJET = 'mailjet'; | |||
const SETTING_MAILER_HOST_SMTP = 'smtp'; | |||
public function __construct() | |||
{ | |||
// général | |||
@@ -35,6 +41,17 @@ class SiteSettingDefinition extends AbstractSettingDefinition implements SiteSet | |||
'name' => self::SETTING_MAINTENANCE_IP_AUTHORIZED, | |||
] | |||
); | |||
$this->addSettingSelect( | |||
[ | |||
'category' => self::CATEGORY_GENERAL, | |||
'name' => self::SETTING_MAILER_HOST, | |||
'choices' => [ | |||
'Mailjet' => self::SETTING_MAILER_HOST_MAILJET, | |||
'SMTP (par défaut alwaysdata)' => self::SETTING_MAILER_HOST_SMTP, | |||
] | |||
] | |||
); | |||
} | |||
public function getCategories(): array | |||
@@ -44,4 +61,4 @@ class SiteSettingDefinition extends AbstractSettingDefinition implements SiteSet | |||
]; | |||
} | |||
} | |||
} |
@@ -120,14 +120,17 @@ class MailMailjetNotification | |||
); | |||
} | |||
// Classique (SMTP) | |||
/*$transport = (new \Swift_SmtpTransport('smtp-placedulocal.alwaysdata.net', 587, 'tls')) | |||
->setUsername('contact@placedulocal.fr') | |||
->setPassword('7sgd5x2BVStJ69'); | |||
$mailer = new \Swift_Mailer($transport); | |||
return $mailer->send($message);*/ | |||
// Mailjet | |||
return $this->transport->send($message); | |||
if($this->settingSolver->getSettingValue($siteDefault, SiteSettingDefinition::SETTING_MAILER_HOST)=== SiteSettingDefinition::SETTING_MAILER_HOST_SMTP){ | |||
$transport = (new \Swift_SmtpTransport( | |||
$this->parameterBag->get('app.mail.host'), | |||
$this->parameterBag->get('app.mail.port'), | |||
$this->parameterBag->get('app.mail.ssl'))) | |||
->setUsername($this->parameterBag->get('app.mail.login')) | |||
->setPassword($this->parameterBag->get('app.mail.password')); | |||
$mailer = new \Swift_Mailer($transport); | |||
return $mailer->send($message); | |||
}else{ | |||
return $this->transport->send($message); | |||
} | |||
} | |||
} |