Я разрабатываю блог под symfony
и для отправки писем использую swiftMailer
.
Я использую этот код в своем контроллере, чтобы отправить всем своим пользователям предупреждение о добавлении новой статьи, но проблема в том, что он показывает мне сообщение об ошибке.
Мой контроллер:
/**
* @Route("/admin/ajout")
* @param Request $request
* @return Response
* @throws \Exception
*/
public function add(Request $request, \Swift_Mailer $mailer): Response {
$article = new Articles();
$addArticle = $this->createForm(ArticlesType::class, $article);
$addArticle->handleRequest($request);
$info = $this->getDoctrine()->getRepository(InfoMore::class)->findByInfo(2);
$em = $this->get('doctrine.orm.entity_manager');
$dql = "SELECT email FROM App:user";
$query = $em->createQuery($dql);
if($addArticle->isSubmitted() && $addArticle->isValid()) {
$article = $addArticle->getData();
$manager = $this->getDoctrine()->getManager();
$manager->persist($article);
$manager->flush();
$message = (new \Swift_Message('Un nouvelles articles est publier'))
->setFrom('[email protected]')
->setTo($query)
->setBody(
$this->renderView(
'email/article_publish.html.twig'
),
'text/html'
)
;
$mailer->send($message);
$this->addFlash('article', 'L\'article a bien étais ajouter');
return $this->redirectToRoute('app_backoffice_admin');
}
return $this->render('backOffice/CRUD/add.html.twig', [
'title' => 'Ajouter un article a votre blog',
'info' => $info,
'addArticle' => $addArticle->createView()
]);
}
и ошибка сообщения:
Адрес в почтовом ящике, заданный [Doctrine\ORM\Query_state], не соответствует RFC 2822, 3.6.2.
Он говорит мне, что адрес недействителен, и в этом случае как добавить несколько адресов электронной почты?
Спасибо за помощь!