Commit 43f1f1da authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Ticket #29787 - Email de l'utilisateur dans le FROM au lieu de ne_pas_repondre@unicaen.fr

parent a445f1bd
Loading
Loading
Loading
Loading
+14 −1
Changes for module/Application/src/Application/Service/ModeleContratService.php: 14 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Application\Service;

use Application\Entity\Db\Contrat;
use Application\Entity\Db\ModeleContrat;
use Application\Service\Traits\ContextServiceAwareTrait;
use Application\Service\Traits\DossierServiceAwareTrait;
use Unicaen\OpenDocument\Document;
use Zend\Mail\Message as MailMessage;
@@ -25,6 +26,8 @@ class ModeleContratService extends AbstractEntityService
{

    use DossierServiceAwareTrait;
    use ContextServiceAwareTrait;


    /**
     * @var array
@@ -133,6 +136,16 @@ class ModeleContratService extends AbstractEntityService
        $text->charset = 'utf-8';
        $body->addPart($text);

        //From on met le mail de l'utilisateur qui envoie le contrat
        $emailFrom = $this->getServiceContext()->getUtilisateur()->getEmail();
        $nameFrom =  $this->getServiceContext()->getUtilisateur()->getDisplayName();
        if(empty($emailFrom))
        {
            //Si pas d'email utilisateur on met la config par défault pour le from
            $emailFrom = \AppConfig::get('mail', 'from');
            $nameFrom = "Application OSE";
        }

        //Contrat en pièce jointe
        $attachment              = new Part($content);
        $attachment->type        = 'application/pdf';
@@ -144,7 +157,7 @@ class ModeleContratService extends AbstractEntityService
        $message     = new MailMessage();
        $messageType = 'multipart/related';
        $message->setEncoding('UTF-8')
            ->setFrom(\AppConfig::get('mail', 'from'), "Application OSE")
            ->setFrom($emailFrom, $nameFrom)
            ->setSubject($subject)
            ->addTo($emailIntervenant)
            ->setBody($body)