other
This commit is contained in:
parent
bdd0325c82
commit
e235986483
2
.env
2
.env
|
@ -44,5 +44,5 @@ SUPPORT_EMAIL=admin_framadate@yopmail.com
|
|||
###< symfony/swiftmailer-bundle ###
|
||||
|
||||
###> symfony/mailer ###
|
||||
# MAILER_DSN=smtp://localhost
|
||||
MAILER_DSN=smtp://localhost
|
||||
###< symfony/mailer ###
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# See https://symfony.com/doc/current/email/dev_environment.html
|
||||
swiftmailer:
|
||||
# send all emails to a specific address
|
||||
delivery_addresses: ['contact@cipherbliss.com']
|
||||
# delivery_addresses: ['contact@cipherbliss.com']
|
||||
|
|
|
@ -9,12 +9,10 @@ use App\Entity\Owner;
|
|||
use App\Entity\Poll;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Exception;
|
||||
use http\Header;
|
||||
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
||||
use Symfony\Component\Mailer\Mailer;
|
||||
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
|
||||
use Symfony\Component\Mime\Address;
|
||||
use Symfony\Component\Mime\Email;
|
||||
|
||||
class MailService {
|
||||
|
||||
|
@ -26,10 +24,12 @@ class MailService {
|
|||
|
||||
private $mailer;
|
||||
|
||||
// public function __construct( EntityManagerInterface $entityManager , Mailer $mailer) {
|
||||
public function __construct( EntityManagerInterface $entityManager ) {
|
||||
$this->em = $entityManager;
|
||||
$transport = new EsmtpTransport();
|
||||
$this->mailer = new Mailer( $transport );
|
||||
// $this->mailer = $mailer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,6 +92,7 @@ class MailService {
|
|||
'email_template' => 'emails/owner-list.html.twig',
|
||||
];
|
||||
$this->sendMailWithVars( $config );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -139,27 +140,36 @@ class MailService {
|
|||
'creation_vote' => 'Framadate | Vote de "' . $config[ 'owner' ]->getPseudo() . '" - sondage ' . $config[ 'poll' ]->getTitle(),
|
||||
];
|
||||
|
||||
// $email = ( new Email() )
|
||||
// ->from( new Address( $config[ 'from' ] ) )
|
||||
//// ->setHeaders( [new Header('charset', 'UTF-8' )])
|
||||
// ->subject( $config[ 'title' ] )
|
||||
// ->to( $config[ 'owner' ]->getEmail() )
|
||||
// ->htmlTemplate( $config[ 'email_template' ] )
|
||||
// ->context( $config );
|
||||
$email = ( new TemplatedEmail() )
|
||||
->from('fabien@example.com')
|
||||
->to(new Address('ryan@example.com'))
|
||||
->subject('Thanks for signing up!')
|
||||
->from( new Address( $config[ 'from' ] ) )
|
||||
// ->setHeaders( [new Header('charset', 'UTF-8' )])
|
||||
->subject( $config[ 'title' ] )
|
||||
->to( $config[ 'owner' ]->getEmail() )
|
||||
->htmlTemplate( $config[ 'email_template' ] )
|
||||
->context( $config );
|
||||
|
||||
// path of the Twig template to render
|
||||
->htmlTemplate('emails/footer.html.twig')
|
||||
|
||||
// pass variables (name => value) to the template
|
||||
->context([
|
||||
'expiration_date' => new \DateTime('+7 days'),
|
||||
'username' => 'foo',
|
||||
])
|
||||
;
|
||||
// $email = ( new \Swift_Mime_SimpleMessage($config[ 'from' ]) )
|
||||
// ->setFrom( new Address( $config[ 'from' ] ) )
|
||||
//// ->setHeaders( [new Header('charset', 'UTF-8' )])
|
||||
// ->setSubject( $config[ 'title' ] )
|
||||
// ->setTo( $config[ 'owner' ]->getEmail() )
|
||||
// ->setBody("ble blah bleuh <strong> strong text </strong> swift mailer","text/html");
|
||||
|
||||
// $email = (new TemplatedEmail())
|
||||
// ->from('fabien@example.com')
|
||||
// ->to(new Address('ryan@example.com'))
|
||||
// ->subject('Thanks for signing up!')
|
||||
//
|
||||
// // path of the Twig template to render
|
||||
// ->htmlTemplate('emails/footer.html.twig')
|
||||
//
|
||||
// // pass variables (name => value) to the template
|
||||
// ->context([
|
||||
// 'expiration_date' => new \DateTime('+7 days'),
|
||||
// 'username' => 'foo',
|
||||
// ])
|
||||
// ;
|
||||
|
||||
// send email
|
||||
return $this->
|
||||
|
|
Loading…
Reference in New Issue