The Wayback Machine - https://web.archive.org/web/20241004160245/https://github.com/symfony/symfony/discussions/46966
Skip to content
\n

My .env file:

\n
###> symfony/mailgun-mailer ###\n# MAILER_DSN=mailgun://2b118****************0a142a30:sandbox5fa7d07406024d5******b.mailgun.org@default?region=us\nMAILER_DSN=mailgun://p******r%40sandbox5fa7d07******************06b.mailgun.org:631a51***********************4-18e06deb-5bfc616f@default?region=us\n###< symfony/mailgun-mailer ###\n
\n

And the php code use to send:

\n
// src/Helper/Mailer.php (custom class)\n \npublic function send($to, $subject, array $context, $template)\n{\n    $email = new TemplatedEmail();\n    $email->to($to) // from est deja defini dans mailer.yaml\n        ->subject($subject)\n        ->htmlTemplate($template)\n        ->context($context);\n    $this->mailerInterface->send($email);\n}\n \npublic function informCommand(Command $command)\n{\n    $subject = 'New Command - JSS Website';\n \n    $context = [\n        'command' => $command\n    ];\n    $this->send(\n        $command->getUser()->getEmail(),\n        $subject,\n        $context,\n        'mail/command.html.twig'\n    ); // Inform User\n \n    $context = [\n        'command' => $command,\n        'user' => $command->getUser()->getFirstName() . ' ' . $command->getUser()->getLastName(),\n        'contact' => $command->getAdress()\n    ];\n    $this->send(\n        '****e*[email protected]',\n        $subject,\n        $context,\n        'mail/command.html.twig'\n    ); // Inform deliverer\n}
\n

Any idea to fix this error please ?

","upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"

See this solution #46979 (comment)

","upvoteCount":2,"url":"https://web.archive.org/web/20241004160245/https://github.com/symfony/symfony/discussions/46966#discussioncomment-3413004"}}}

Unable to send an email : Forbidden (code 401) with Mailgun #46966

Answered by lyrixx
Asmitta-01 asked this question in Q&A
Discussion options

You must be logged in to vote

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
7 replies
@lyrixx
Comment options

@Asmitta-01
Comment options

@alexislefebvre
Comment options

@Asmitta-01
Comment options

@alexislefebvre
Comment options

Comment options

You must be logged in to vote
1 reply
@stof
Comment options

Answer selected by lyrixx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants