start working on trade email sending

This commit is contained in:
Jannis Portmann 2021-05-28 11:23:04 +02:00
parent 222d35e1b4
commit bed4012971
2 changed files with 44 additions and 0 deletions

View file

@ -0,0 +1,39 @@
<?php
namespace App\Controller;
use App\Repository\OfferingRepository;
use App\Repository\WishRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
use Symfony\Component\Routing\Annotation\Route;
class TradeController extends AbstractController
{
#[Route('/trade/{id}', name: 'trade')]
public function sendEmail(MailerInterface $mailer, OfferingRepository $offeringRepository, WishRepository $wishRepository): Response
{
$user = $this->getUser();
$offer = $offeringRepository->();
if(/* user not the logged in user */)
$email = (new Email())
->from('no-reply@pfleanz.li')
->to(/* user of offer */)
->replyTo(/* logged in user */)
->subject('Time for Symfony Mailer!')
->text('Sending emails is fun again!')
->htmlTemplate('user/trade/offer_email.html.twig');
try
{
$mailer->send($email);
} catch (TransportExceptionInterface $e) {
// TODO:
// print error
}
return $this->redirectToRoute('/offer', {'id': $id});
}
}

View file

@ -0,0 +1,5 @@
<h1>{{ user.username}} wants to trade!</h1>
<p>You can checkout their offer and reply to this email if you want to trade.</p>
<a href={{ path('user_public', id: { 'id': offer.byuser.id }) }}</a>