This commit is contained in:
afornerot 2020-01-16 16:00:43 +01:00
commit e7e5c5f618
6 changed files with 43 additions and 8 deletions

View File

@ -293,7 +293,10 @@
<!-- 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_smtpport' description='Port 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_noreply</target>
<target type='variable'>ninegate_activer_localmail</target>
<target type='variable'>ninegate_smtphost</target>
<target type='variable'>ninegate_smtpport</target>
<target type='variable'>ninegate_smtpuser</target>
@ -1137,6 +1141,17 @@
</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 -->

View File

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

View File

@ -1,4 +1,10 @@
#!/bin/bash
cd /var/www/html/ninegate
php bin/console swiftmailer:spool:send --message-limit=100 --env=prod
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
fi

View File

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

View File

@ -30,6 +30,12 @@ parameters:
database_name: ninegate
database_user: ninegate
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
%if %%is_defined("ninegate_smtphost")
mailer_host: '%%ninegate_smtphost'
@ -39,5 +45,6 @@ parameters:
mailer_host: 'localhost'
mailer_user: ''
mailer_password: ''
%end if
%end if
secret: ThisTokenIsNotSoSecretChangeIt

View File

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