1 pièce(s) jointe(s)
Envoi de mail avec symfony
Bonjour, je suis actuellement en train de faire un projet symfony 5 et je me suis tenté à l'envoi de mail sans succès. J'utilise le MailerInterface et j'ai également suivi la documentation symfony sauf que cela ne me retourne aucune erreur et cela n'envoie pas de mail. Auriez-vous des pistes ?
Voici une partie de mon controller (c'est un controller d'inscription, dès que quelqu'un souhaite s'inscrire je veux envoyer un mail à un admin afin de valider ou non l'inscription) :
Code:
1 2 3 4 5 6 7 8 9 10 11
| $mail = (new Email())
->from('******@gmail.com')
->to('****@gmail.com')
->subject('Yo')
->text('Clara')
->html('<p>Coucou</p>');
$transport = new GmailTransport('localhost');
$mail = new Mailer($transport);
//on envoie le mail
$mailer->send($mail); |
Sachant que j'utilise Gmail j'ai également modifié le .env :
Code:
1 2 3 4
| ###> symfony/mailer ###
# MAILER_DSN=smtp://localhost
MAILER_DSN=gmail+smtp://*****:*****@default
###< symfony/mailer ### |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| ###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://*****:*****@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
MAILER_URL=null://localhost:1025
MAILER_URL=gmail://*****:*****@localhost
###< symfony/swiftmailer-bundle ###
###> symfony/google-mailer ###
# Gmail SHOULD NOT be used on production, use it in development only.
# GMAIL_USERNAME=*****
# GMAIL_PASSWORD=*****
# MAILER_DSN=smtp://$GMAIL_USERNAME:$GMAIL_PASSWORD@gmail
###< symfony/google-mailer ### |
Le "webmail" de symfony apparaît en "down" lorsque je consulte une page de mon site :
Pièce jointe 572557
Cela a-t-il un impact ?
J'ai également vérifié le phpinfo, le serveur reconnait bien l'adresse mail hôte mais cela ne veut toujours pas envoyer de mail.
Merci d'avance