/
vladislavts
/
gcppmsp
Обзор
Документация
Войти
/
vladislavts
/
gcppmsp
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
prod
src/Services/MailService.php
43 строки
1 KB
vladislav_ts@list.ru
+ пасс генератор сервис. + смена паролей всем
10 сен 2024, 20:17
10 сен 2024, 20:17
0747c90
Код
Авторство
О чём код?
<?php namespace App\Services; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Mailer\MailerInterface; use Symfony\Component\Mime\Address; use Symfony\Component\Mime\Email; class MailService { private MailerInterface $mailer; private ParameterBagInterface $params; public function __construct(MailerInterface $mailer, ParameterBagInterface $params) { $this->mailer = $mailer; $this->params = $params; } public function sendMail($fromName, $toEmail, $textMail, bool $toAdmin = false) { $fromEmail = $this->params->get('mail_sender'); if ($toAdmin) { $toEmail = "vladislavts88@gmail.com"; } $email = (new Email()) ->from(new Address($fromEmail, $fromName)) ->to($toEmail) //->cc('cc@example.com') //->bcc('bcc@example.com') //->replyTo('fabien@example.com') //->priority(Email::PRIORITY_HIGH) ->subject('Почта от гпмпк') ->text($textMail) ; $this->mailer->send($email); usleep(500000); } }