mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
send mailer without swift
This commit is contained in:
parent
c5f3e7a221
commit
88da8b824a
4
.env
4
.env
@ -42,3 +42,7 @@ MAILER_URL=sendmail://framadate-api.cipherbliss.com
|
||||
# set the support email who will answer users in case of emergency
|
||||
SUPPORT_EMAIL=admin_framadate@yopmail.com
|
||||
###< symfony/swiftmailer-bundle ###
|
||||
|
||||
###> symfony/mailer ###
|
||||
# MAILER_DSN=smtp://localhost
|
||||
###< symfony/mailer ###
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"type": "project",
|
||||
"license": "proprietary",
|
||||
"license": "AGPLv3",
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"ext-ctype": "*",
|
||||
@ -11,6 +11,7 @@
|
||||
"nelmio/api-doc-bundle": "^3.4",
|
||||
"nelmio/cors-bundle": "^2.0",
|
||||
"sensio/framework-extra-bundle": "^5.5",
|
||||
"swiftmailer/swiftmailer": "^6.0",
|
||||
"symfony/config": "4.3.*",
|
||||
"symfony/console": "4.3.*",
|
||||
"symfony/dependency-injection": "4.3.*",
|
||||
@ -19,6 +20,7 @@
|
||||
"symfony/form": "4.3.*",
|
||||
"symfony/framework-bundle": "4.3.*",
|
||||
"symfony/intl": "4.3.*",
|
||||
"symfony/mailer": "4.3.*",
|
||||
"symfony/maker-bundle": "^1.14",
|
||||
"symfony/orm-pack": "^1.0",
|
||||
"symfony/swiftmailer-bundle": "^3.4",
|
||||
|
64
composer.lock
generated
64
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "faabf0bb9999cd406634d3ab22880cdf",
|
||||
"content-hash": "3131df97f0b3bc59550652b3fbef5a6c",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/annotations",
|
||||
@ -4461,6 +4461,68 @@
|
||||
],
|
||||
"time": "2020-01-04T12:24:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/mailer",
|
||||
"version": "v4.3.11",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/mailer.git",
|
||||
"reference": "9f1067430479527a21d9dc8461d97f4fbd1907de"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/mailer/zipball/9f1067430479527a21d9dc8461d97f4fbd1907de",
|
||||
"reference": "9f1067430479527a21d9dc8461d97f4fbd1907de",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"egulias/email-validator": "^2.1.10",
|
||||
"php": "^7.1.3",
|
||||
"psr/log": "~1.0",
|
||||
"symfony/event-dispatcher": "^4.3",
|
||||
"symfony/mime": "^4.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/amazon-mailer": "^4.3",
|
||||
"symfony/google-mailer": "^4.3",
|
||||
"symfony/http-client-contracts": "^1.1",
|
||||
"symfony/mailchimp-mailer": "^4.3.3",
|
||||
"symfony/mailgun-mailer": "^4.3.3",
|
||||
"symfony/postmark-mailer": "^4.3.3",
|
||||
"symfony/sendgrid-mailer": "^4.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Mailer\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Mailer Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2020-01-01T11:51:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/maker-bundle",
|
||||
"version": "v1.14.3",
|
||||
|
3
config/packages/mailer.yaml
Normal file
3
config/packages/mailer.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
framework:
|
||||
mailer:
|
||||
dsn: '%env(MAILER_DSN)%'
|
@ -9,8 +9,10 @@ use App\Entity\Poll;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Exception;
|
||||
use Swift_Mailer;
|
||||
use Swift_Message;
|
||||
use Symfony\Component\Mailer\Mailer;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
||||
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
|
||||
use Symfony\Component\Mime\Address;
|
||||
use Symfony\Component\Mime\Email;
|
||||
|
||||
@ -21,17 +23,19 @@ class MailService {
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
private $em;
|
||||
/**
|
||||
* @var Swift_Mailer
|
||||
*/
|
||||
|
||||
private $mailer;
|
||||
|
||||
public function __construct( EntityManagerInterface $entityManager, Swift_Mailer $mailer ) {
|
||||
public function __construct( EntityManagerInterface $entityManager ) {
|
||||
$this->em = $entityManager;
|
||||
|
||||
|
||||
$transport = new EsmtpTransport();
|
||||
$mailer = new Mailer($transport);
|
||||
$this->mailer = $mailer;
|
||||
}
|
||||
|
||||
public function sendCreationMailAction( Owner $foundOwner, Poll $newpoll, Swift_Mailer $mailer ) {
|
||||
public function sendCreationMailAction( Owner $foundOwner, Poll $newpoll, MailerInterface $mailer ) {
|
||||
$em = $this->em->getRepository( Owner::class );
|
||||
$admin_user = $foundOwner;
|
||||
$poll = $newpoll;
|
||||
@ -69,9 +73,6 @@ class MailService {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function sendOwnerPollsAction( Owner $foundOwner ) {
|
||||
$em = $this->em->getRepository( Owner::class );
|
||||
$admin_user = $foundOwner;
|
||||
|
||||
|
||||
// anti spam , limit to every minute TODO
|
||||
// $lastSend = $admin_user->getRequestedPollsDate();
|
||||
@ -87,14 +88,14 @@ class MailService {
|
||||
$titleEmail = 'Framadate | Mes sondages';
|
||||
|
||||
$templateVars = [
|
||||
'owner' => $admin_user,
|
||||
'owner' => $foundOwner,
|
||||
'title' => $titleEmail,
|
||||
'email_template' => 'emails/owner-list.html.twig',
|
||||
];
|
||||
|
||||
$email = ( new TemplatedEmail() )
|
||||
->from( 'ne-pas-repondre@framadate-api.cipherbliss.com' )
|
||||
->to( new Address( $admin_user->getEmail() ) )
|
||||
->to( new Address( $foundOwner->getEmail() ) )
|
||||
->subject( $titleEmail )
|
||||
->htmlTemplate( $templateVars[ 'email_template' ] )
|
||||
->context( $templateVars );
|
||||
|
12
symfony.lock
12
symfony.lock
@ -332,6 +332,18 @@
|
||||
"symfony/intl": {
|
||||
"version": "v4.3.5"
|
||||
},
|
||||
"symfony/mailer": {
|
||||
"version": "4.3",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "master",
|
||||
"version": "4.3",
|
||||
"ref": "15658c2a0176cda2e7dba66276a2030b52bd81b2"
|
||||
},
|
||||
"files": [
|
||||
"config/packages/mailer.yaml"
|
||||
]
|
||||
},
|
||||
"symfony/maker-bundle": {
|
||||
"version": "1.0",
|
||||
"recipe": {
|
||||
|
Loading…
Reference in New Issue
Block a user