Example #1
0
 public function send(MailInterface $mail)
 {
     if (!$mail instanceof PhpMailerMail) {
         throw new RuntimeException(sprintf("Mail must be of instance %s to be sent using %s", PhpMailerMail::class, PhpMailer::class));
     }
     $receiver = $mail->getTo();
     $this->phpMailer->Subject = $mail->getSubject();
     $this->phpMailer->Body = $mail->getBody();
     $this->phpMailer->From = $mail->getFromEmail();
     $this->phpMailer->FromName = $mail->getFromName();
     $this->phpMailer->WordWrap = 50;
     $this->phpMailer->addAddress($receiver['email'], $receiver['name']);
     $this->phpMailer->addReplyTo($mail->getFromEmail(), $mail->getFromName());
     $this->phpMailer->isHTML(true);
     if (!$this->phpMailer->send()) {
         throw new \RuntimeException($this->phpMailer->ErrorInfo);
     }
 }