Commit 6026d03b authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Suppression de laminas/mail et remplacement par symfony/mail

parent 5ac4b83f
Loading
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -15,12 +15,9 @@
        }
    ],
    "require"     : {
        "laminas/laminas-mail": "^2.10",
        "laminas/laminas-mime": "^2.7"
    },
    "require-dev" : {
        "phpunit/PHPUnit": "^5.6"
        "symfony/mailer": "^7"
    },

    "autoload"    : {
        "psr-0"   : {
            "UnicaenSiham": "src/"
+21 −16
Original line number Diff line number Diff line
@@ -3,6 +3,10 @@
namespace UnicaenSiham\Service;


use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
use Symfony\Component\Mime\Email;
use UnicaenSiham\Entity\Agent;
use UnicaenSiham\Exception\SihamException;
use Laminas\Mail\Message;
@@ -1435,7 +1439,7 @@ class Siham



    public function sendDebug($message = '', $exception = null)
    public function sendDebug($message = '', $exception = null): bool
    {
        $config = $this->sihamConfig;
        if ($config['debug']['activate'] === false) {
@@ -1462,26 +1466,27 @@ class Siham
        $body .= "----------------------------------------------------";
        $body .= $this->sihamClient->getLastResponse();

        $mail = new Message();
        $mail->setBody($body);
        $mail->setFrom($config['debug']['from'], 'Application OSE');
        $mail->addTo($config['debug']['to']);
        $mail = new Email();
        $mail->html($body);
        $mail->from($config['debug']['from'], 'Application OSE');
        $mail->to($config['debug']['to']);

        if (!empty($exception)) {
            $mail->setSubject('Exception Siham' . ' / ' . $message);
            $mail->subject('Exception Siham' . ' / ' . $message);
        } else {
            $mail->setSubject('Debug Siham' . ' / ' . $message);
            $mail->subject('Debug Siham' . ' / ' . $message);
        }

        $options = new SmtpOptions([
            'name' => $config['debug']['smtpHost'],
            'host' => $config['debug']['smtpHost'],
            'port' => $config['debug']['smtpPort'],
        ]);
        $transport = new EsmtpTransport(host: $config['debug']['smtpHost'], port:$config['debug']['smtpPort']);
        $mailer = new Mailer($transport);

        $transport = new SmtpTransport();
        $transport->setOptions($options);

        $transport->send($mail);
        try{
            $mailer->send($mail);
            return true;
        }
        catch(TransportExceptionInterface $e)
        {
            return false;
        }
    }
}
 No newline at end of file