Commit 28efaad7 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Changement du comportement de sendMail : un objet mail est maintenant renvoyé...

Changement du comportement de sendMail : un objet mail est maintenant renvoyé même si doNotSend est true
parent 3a5d8fab
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ class Mail {
    const PENDING = 'PENDING';
    const SUCCESS = 'SUCCESS';
    const FAILED  = 'FAILED';
    const NOTSENT  = 'NOT SENT';
    const MOTCLEF_SEPARATEUR = '||';

    private ?int $id = null;
+19 −17
Original line number Diff line number Diff line
@@ -174,10 +174,7 @@ class MailService {
            throw new RuntimeException("Un problème est survenu lors de la récupération de valeurs de config",0,$e);
        }

        if ($doNotSend === true)
        {
            return null;
        }


        if (is_string($to)) $to=explode(',', $to);
        if (!is_array($to)) $to = [$to];
@@ -253,6 +250,9 @@ class MailService {
                $parts[] = $attachement;
            }
        }

        if ($doNotSend !== true)
        {
            $body = new MimeMessage();
            $body->setParts($parts);
            $message->setBody($body);
@@ -264,8 +264,10 @@ class MailService {
    //        var_dump($subjectPrefix);
    //        die();
            $this->transport->send($message);

            $mail->setStatusEnvoi(Mail::SUCCESS);
        } else {
            $mail->setStatusEnvoi(Mail::NOTSENT);
        }
        $this->update($mail);

        return $mail;