Unable to send an email : Forbidden (code 401) with Mailgun #46966
Answered
by
lyrixx
Asmitta-01
asked this question in
Q&A
-
Hey, i'm trying to send an email with mailgun but i'm always getting this error:
My .env file:
And the php code use to send: // src/Helper/Mailer.php (custom class)
public function send($to, $subject, array $context, $template)
{
$email = new TemplatedEmail();
$email->to($to) // from est deja defini dans mailer.yaml
->subject($subject)
->htmlTemplate($template)
->context($context);
$this->mailerInterface->send($email);
}
public function informCommand(Command $command)
{
$subject = 'New Command - JSS Website';
$context = [
'command' => $command
];
$this->send(
$command->getUser()->getEmail(),
$subject,
$context,
'mail/command.html.twig'
); // Inform User
$context = [
'command' => $command,
'user' => $command->getUser()->getFirstName() . ' ' . $command->getUser()->getLastName(),
'contact' => $command->getAdress()
];
$this->send(
'****e*eu@gmail.com',
$subject,
$context,
'mail/command.html.twig'
); // Inform deliverer
} Any idea to fix this error please ? |
Beta Was this translation helpful? Give feedback.
Answered by
lyrixx
Aug 17, 2022
Replies: 2 comments 8 replies
-
Please any idea ? |
Beta Was this translation helpful? Give feedback.
7 replies
-
See this solution #46979 (comment) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
lyrixx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See this solution #46979 (comment)