Skip to content

Commit

Permalink
afup#1416 mails
Browse files Browse the repository at this point in the history
  • Loading branch information
stakovicz committed Jan 7, 2024
1 parent 6d43eed commit d15c6b4
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 36 deletions.
15 changes: 13 additions & 2 deletions app/config/parameters.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ parameters:
database_name: symfony
database_user: root
database_password: ~

slack_url: ""
# You should uncomment this if you want use pdo_sqlite
# database_path: "%kernel.root_dir%/data.db3"

# A secret key that's used to generate certain security-related tokens
secret: ThisTokenIsNotSoSecretChangeIt
Expand All @@ -23,6 +23,9 @@ parameters:

home_algolia_enabled: false

# Slack url for notifications
slack_url: 'http://yolo'

twitter_oauth_access_token: ""
twitter_oauth_access_token_secret: ""
twitter_consumer_key: ""
Expand Down Expand Up @@ -69,3 +72,11 @@ parameters:
paybox_identifiant: "110647233"

blog_api_key: 123456

mails_serveur_smtp: "mailcatcher"
mails_tls: 0
mails_username: ""
mails_password: ""
mails_port: 1025
mails_force_destinataire: []
mails_bcc: []
8 changes: 8 additions & 0 deletions app/config/parameters.yml.dist-docker
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,11 @@ parameters:
paybox_identifiant: "110647233"

blog_api_key: 123456

mails_serveur_smtp: "mailcatcher"
mails_tls: 0
mails_username: ""
mails_password: ""
mails_port: 1025
mails_force_destinataire: []
mails_bcc: []
9 changes: 0 additions & 9 deletions configs/application/config-test.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
<?php
$configuration['web']['path']='/';

$configuration['mails']['serveur_smtp']='mailcatcher';
$configuration['mails']['email_expediteur']='[email protected]';
$configuration['mails']['nom_expediteur']='Bureau AFUP';
$configuration['mails']['force_destinataire']='';
$configuration['mails']['bcc']='';
$configuration['mails']['tls']='0';
$configuration['mails']['port']='1025';
$configuration['mails']['username']='';
$configuration['mails']['password']='';
$configuration['afup']['raison_sociale']='AFUP';
$configuration['afup']['adresse']='32, Boulevard de Strasbourg
CS 30108';
Expand Down
9 changes: 0 additions & 9 deletions configs/application/config.php.dist
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
<?php
$configuration['web']['path']='http://.dev/';

$configuration['mails']['serveur_smtp']='';
$configuration['mails']['email_expediteur']='[email protected]';
$configuration['mails']['nom_expediteur']='Bureau AFUP';
$configuration['mails']['force_destinataire']='';
$configuration['mails']['bcc']='[email protected]';
$configuration['mails']['tls']='0';
$configuration['mails']['port']='';
$configuration['mails']['username']='';
$configuration['mails']['password']='';
$configuration['afup']['raison_sociale']='AFUP';
$configuration['afup']['adresse']='32, Boulevard de Strasbourg
CS 30108';
Expand Down
9 changes: 0 additions & 9 deletions configs/application/config.php.dist-docker
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
<?php
$configuration['web']['path']='/';

$configuration['mails']['serveur_smtp']='mailcatcher';
$configuration['mails']['email_expediteur']='[email protected]';
$configuration['mails']['nom_expediteur']='Bureau AFUP';
$configuration['mails']['force_destinataire']='';
$configuration['mails']['bcc']='[email protected]';
$configuration['mails']['tls']='0';
$configuration['mails']['port']='1025';
$configuration['mails']['username']='';
$configuration['mails']['password']='';
$configuration['afup']['raison_sociale']='AFUP';
$configuration['afup']['adresse']='32, Boulevard de Strasbourg
CS 30108';
Expand Down
3 changes: 1 addition & 2 deletions sources/Afup/Association/Cotisations.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ function notifierRegelementEnLigneAuTresorier($cmd, $total, $autorisation, $tran
$corps .= "Autorisation : " . $autorisation . "\n";
$corps .= "Transaction : " . $transaction . "\n\n";

$expediteur = $GLOBALS['AFUP_CONF']->obtenir('mails|email_expediteur');
$ok = Mailing::envoyerMail(new Message($sujet, new MailUser($expediteur), MailUserFactory::tresorier()), $corps);
$ok = Mailing::envoyerMail(new Message($sujet, new MailUser(Mailing::EMAIL_EXPEDITEUR, Mailing::NOM_EXPEDITEUR), MailUserFactory::tresorier()), $corps);

if (false === $ok) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions sources/Afup/Comptabilite/Facture.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Afup\Site\Comptabilite;

use Afup\Site\Utils\Mail;
use Afup\Site\Utils\Mailing;
use Afup\Site\Utils\Pays;
use Afup\Site\Utils\PDF_Facture;
Expand Down Expand Up @@ -735,8 +736,7 @@ function envoyerFacture($reference)
$chemin_facture = AFUP_CHEMIN_RACINE . 'cache' . DIRECTORY_SEPARATOR . 'fact' . $reference . '.pdf';
$this->genererFacture($reference, $chemin_facture);

$expediteur = $GLOBALS['AFUP_CONF']->obtenir('mails|email_expediteur');
$message = new Message($sujet, new MailUser($expediteur), new MailUser($personne['email'], $personne['nom']));
$message = new Message($sujet, new MailUser(Mailing::EMAIL_EXPEDITEUR, Mailing::NOM_EXPEDITEUR), new MailUser($personne['email'], $personne['nom']));
$message->addAttachment(new Attachment(
$chemin_facture,
'facture-'.$reference.'.pdf',
Expand Down
9 changes: 9 additions & 0 deletions sources/Afup/Utils/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ public function __construct($chemin_fichier)
$this->_valeurs['bdd']['base'] = $parameters['database_name'];
$this->_valeurs['bdd']['utilisateur'] = $parameters['database_user'];
$this->_valeurs['bdd']['mot_de_passe'] = $parameters['database_password'];

$this->_valeurs['mails']['serveur_smtp'] = $parameters['mails_serveur_smtp'];
$this->_valeurs['mails']['tls'] = $parameters['mails_tls'];
$this->_valeurs['mails']['username'] = $parameters['mails_username'];
$this->_valeurs['mails']['password'] = $parameters['mails_password'];
$this->_valeurs['mails']['port'] = $parameters['mails_port'];

$this->_valeurs['mails']['force_destinataire'] = $parameters['mails_force_destinataire'];
$this->_valeurs['mails']['bcc'] = $parameters['mails_bcc'];
}
}

Expand Down
3 changes: 3 additions & 0 deletions sources/Afup/Utils/Mailing.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

class Mailing
{
const EMAIL_EXPEDITEUR = '[email protected]';
const NOM_EXPEDITEUR = 'Bureau AFUP';

/**
* @param Message $message
* @param string $body
Expand Down
5 changes: 2 additions & 3 deletions sources/AppBundle/Association/UserMembership/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace AppBundle\Association\UserMembership;

use Afup\Site\Association\Cotisations;
use Afup\Site\Utils\Configuration;
use Afup\Site\Utils\Mailing;
use AppBundle\Association\Model\Repository\UserRepository;
use AppBundle\Association\Model\User;
use AppBundle\Email\Mailer\Mailer;
Expand All @@ -29,14 +29,13 @@ public function __construct(
UserRepository $userRepository,
Mailer $mailer,
UrlGeneratorInterface $urlGenerator,
Configuration $configuration,
Cotisations $cotisations
) {
$this->userRepository = $userRepository;
$this->mailer = $mailer;
$this->urlGenerator = $urlGenerator;
$this->cotisations = $cotisations;
$this->sender = $configuration->obtenir('mails|email_expediteur');
$this->sender = Mailing::EMAIL_EXPEDITEUR;
}

public function generateRandomPassword()
Expand Down

0 comments on commit d15c6b4

Please sign in to comment.