<?php
@ini_set('max_execution_time', '-1');

require 'vendor/autoload.php';

use Symfony\Component\Mailer\Transport;
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mime\Email;

try {
    // Configure the SMTP transport
    $dsn = 'smtp://no-reply%40jsc.ma:welcome%40jsc%40ma@smtp.gmail.com:465?encryption=ssl';
    $transport = Transport::fromDsn($dsn);

    // Create the Mailer
    $mailer = new Mailer($transport);

    // Build the email
    $email = (new Email())
        ->from('no-reply@jsc.ma')
        ->to('mehdidev@creaweb.ma')
        ->replyTo('ano-reply@jsc.ma')
        ->subject('Message from jsc.ma')
        ->html('This is a message from jsc.ma smtp service.');

    // Send the email
    $mailer->send($email);

    echo 'Message has been sent';
} catch (Exception $e) {
    echo "Message could not be sent. Error: {$e->getMessage()}";
}
