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
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}
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"}}}-
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*[email protected]',
$subject,
$context,
'mail/command.html.twig'
); // Inform deliverer
} Any idea to fix this error please ? |
Beta Was this translation helpful? Give feedback.
-
Please any idea ? |
Beta Was this translation helpful? Give feedback.
-
See this solution #46979 (comment) |
Beta Was this translation helpful? Give feedback.
See this solution #46979 (comment)