pouvoir utiliser le serveur d'envoi de mail local au scribe (fixes #26)

This commit is contained in:
Arnaud Fornerot 2020-01-13 15:47:35 +01:00
parent 35b61480a2
commit 31fbeaf621
6 changed files with 43 additions and 8 deletions

View File

@ -294,6 +294,9 @@
<!-- EMAIL --> <!-- EMAIL -->
<variable type='string' name='ninegate_noreply' description='Adresse mail utilisé pour le noreply' mandatory='True' /> <variable type='string' name='ninegate_noreply' description='Adresse mail utilisé pour le noreply' mandatory='True' />
<variable type="oui/non" name='ninegate_activer_localmail' description="Utiliser le serveur d'envoi de mail local" mandatory='True'>
<value>oui</value>
</variable>
<variable type='string' name='ninegate_smtphost' description='Host du serveur SMTP' /> <variable type='string' name='ninegate_smtphost' description='Host du serveur SMTP' />
<variable type='string' name='ninegate_smtpport' description='Port du serveur SMTP' /> <variable type='string' name='ninegate_smtpport' description='Port du serveur SMTP' />
<variable type='string' name='ninegate_smtpuser' description='Compte du serveur SMTP' /> <variable type='string' name='ninegate_smtpuser' description='Compte du serveur SMTP' />
@ -391,6 +394,7 @@
<target type='variable'>ninegate_activate_websocket</target> <target type='variable'>ninegate_activate_websocket</target>
<target type='variable'>ninegate_noreply</target> <target type='variable'>ninegate_noreply</target>
<target type='variable'>ninegate_activer_localmail</target>
<target type='variable'>ninegate_smtphost</target> <target type='variable'>ninegate_smtphost</target>
<target type='variable'>ninegate_smtpport</target> <target type='variable'>ninegate_smtpport</target>
<target type='variable'>ninegate_smtpuser</target> <target type='variable'>ninegate_smtpuser</target>
@ -1137,6 +1141,17 @@
</auto> </auto>
<!-- AFFICHAGE EN FONCTION DU MAIL -->
<condition name='hidden_if_in' source='ninegate_activer_localmail'>
<param>oui</param>
<target type='variable'>ninegate_smtphost</target>
<target type='variable'>ninegate_smtpport</target>
<target type='variable'>ninegate_smtpuser</target>
<target type='variable'>ninegate_smtppwd</target>
<target type='variable'>ninegate_smtpencryption</target>
<target type='variable'>ninegate_smtpauthmode</target>
</condition>
<!-- AFFICHAGE EN FONCTION DU MODE DE BDD --> <!-- AFFICHAGE EN FONCTION DU MODE DE BDD -->

View File

@ -29,7 +29,7 @@ services:
public: true public: true
tags: ['controller.service_arguments'] tags: ['controller.service_arguments']
# add more services, or override services that need manual wiring swiftmailer.mailer.sendmail.transport:
# AppBundle\Service\ExampleService: class: Swift_SendmailTransport
# arguments: public: true
# $someArgument: 'some_value' arguments: ['/usr/sbin/sendmail -t']

View File

@ -1,4 +1,10 @@
#!/bin/bash #!/bin/bash
cd /var/www/html/ninegate cd /var/www/html/ninegate
ninegate_activer_localmail=$(CreoleGet ninegate_activer_localmail non)
if [[ "$ninegate_activer_localmail" = 'oui' ]]
then
php bin/console swiftmailer:spool:send --message-limit=100 --env=prod --transport swiftmailer.mailer.sendmail.transport
else
php bin/console swiftmailer:spool:send --message-limit=100 --env=prod php bin/console swiftmailer:spool:send --message-limit=100 --env=prod
fi

View File

@ -2,6 +2,7 @@
namespace Cadoles\CronBundle\Command; namespace Cadoles\CronBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
@ -12,7 +13,7 @@ use Symfony\Component\HttpFoundation\Response;
use Cadoles\CronBundle\Entity\Cron; use Cadoles\CronBundle\Entity\Cron;
class MailCommand extends Command class MailCommand extends ContainerAwareCommand
{ {
private $container; private $container;
private $em; private $em;
@ -41,6 +42,8 @@ class MailCommand extends Command
$this->filesystem = new Filesystem(); $this->filesystem = new Filesystem();
$this->rootlog = $this->container->get('kernel')->getRootDir()."/../var/logs/"; $this->rootlog = $this->container->get('kernel')->getRootDir()."/../var/logs/";
$mailer_host = $this->getContainer()->getParameter('cron_activate');
$this->writelnred(''); $this->writelnred('');
$this->writelnred('== Cron:Mail'); $this->writelnred('== Cron:Mail');
$this->writelnred('=========================================================================================================='); $this->writelnred('==========================================================================================================');
@ -48,6 +51,10 @@ class MailCommand extends Command
$command = $this->getApplication()->find("swiftmailer:spool:send"); $command = $this->getApplication()->find("swiftmailer:spool:send");
$tbparameter["--message-limit"]=100; $tbparameter["--message-limit"]=100;
$tbparameter["--env"]="prod"; $tbparameter["--env"]="prod";
if($mailer_host=="/usr/sbin/sendmail")
$tbparameter["--transport"]="swiftmailer.mailer.sendmail.transport";
$parameter = new ArrayInput($tbparameter); $parameter = new ArrayInput($tbparameter);
try{ try{
$returnCode = $command->run($parameter, $output); $returnCode = $command->run($parameter, $output);

View File

@ -30,6 +30,12 @@ parameters:
database_name: ninegate database_name: ninegate
database_user: ninegate database_user: ninegate
database_password: "changeme" database_password: "changeme"
%if %%getVar("ninegate_activer_localmail", 'non') == "oui"
mailer_transport: sendmail
mailer_host: '/usr/sbin/sendmail'
mailer_user: ~
mailer_password: ~
%else
mailer_transport: smtp mailer_transport: smtp
%if %%is_defined("ninegate_smtphost") %if %%is_defined("ninegate_smtphost")
mailer_host: '%%ninegate_smtphost' mailer_host: '%%ninegate_smtphost'
@ -39,5 +45,6 @@ parameters:
mailer_host: 'localhost' mailer_host: 'localhost'
mailer_user: '' mailer_user: ''
mailer_password: '' mailer_password: ''
%end if
%end if %end if
secret: ThisTokenIsNotSoSecretChangeIt secret: ThisTokenIsNotSoSecretChangeIt

View File

@ -408,7 +408,7 @@ parameters:
mailer_port: '2525' mailer_port: '2525'
mailer_encryption: null mailer_encryption: null
mailer_authmode: null mailer_authmode: null
noreply: %%system_mail_to noreply: %%ninegate_noreply
%end if %end if
# Doctrine Configuration # Doctrine Configuration