getUser(); if($user != $offer->getByUser()) { $email = (new TemplatedEmail()) ->from('no-reply@thisfro.ch') ->to($offer->getByUser()->getEmail()) ->replyTo($user->getEmail()) ->subject($user->getUsername() . ' wants to trade with you!') ->text('Trade offer') ->htmlTemplate('user/trade/offer_email.html.twig') ->context([ 'user' => $user, 'id' => $user->getId(), ]) ; try { $mailer->send($email); $this->addFlash('success', 'Trade offer sent!'); } catch (TransportExceptionInterface $e) { $this->addFlash('error', 'There was an error: ' . $e); } } else { $this->addFlash('error','You can\'t trade with yourself!'); } return $this->redirectToRoute('show_offer', ['id' => $offer->getId()]); } }