1
0
mirror of https://framagit.org/tykayn/date-poll-api synced 2023-08-25 08:23:11 +02:00

hop email template

This commit is contained in:
tykayn 2020-04-14 18:13:48 +02:00
parent 9b7f2ebd32
commit 81b27811c2
2 changed files with 16 additions and 18 deletions

View File

@ -20,7 +20,7 @@ class DefaultController extends AbstractController {
*/
private $mail_service;
public function __construct(MailService $mail_service) {
public function __construct( MailService $mail_service ) {
$this->mail_service = $mail_service;
}
@ -51,23 +51,21 @@ class DefaultController extends AbstractController {
];
// send email
$this->mail_service->sendOwnerPollsAction();
if ( $this->mail_service->sendOwnerPollsAction( $founduser ) ) {
return $this->json( [
'message' => 'mail succefully sent to user ' . $email,
'data' => '',
],
200 );
} else { // user not found case
return $this->json( [
'message' => 'no user found for email ' . $email,
'data' => '',
],
400 );
}
return $this->json( [
'message' => 'mail succefully sent to user ' . $email,
'data' => '',
],
200 );
} else { // user not found case
return $this->json( [
'message' => 'no user found for email ' . $email,
'data' => '',
],
400 );
}

View File

@ -98,14 +98,14 @@ class MailService {
'email_template' => 'emails/owner-polls.html.twig',
];
$email = ( new TemplatedEmail( $titleEmail ) )
$email = ( new TemplatedEmail( ) )
->from( 'ne-pas-repondre@framadate-api.cipherbliss.com' )
->to( new Address($admin_user->getEmail() ) )
->subject($titleEmail)
->htmlTemplate($templateVars[ 'email_template' ])
->context( $templateVars);
// send email
return $this->mailer->send( $email );
}
}