const SETTING_EMAIL_FROM = 'emailFrom'; | const SETTING_EMAIL_FROM = 'emailFrom'; | ||||
const SETTING_EMAIL_FROM_NAME = 'emailFromName'; | 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() | public function __construct() | ||||
{ | { | ||||
// général | // général | ||||
'name' => self::SETTING_MAINTENANCE_IP_AUTHORIZED, | '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 | public function getCategories(): array | ||||
]; | ]; | ||||
} | } | ||||
} | |||||
} |
); | ); | ||||
} | } | ||||
// 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); | |||||
} | |||||
} | } | ||||
} | } |