Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 18 |
App\Models\Email | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 18 |
getInstance | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 5 |
|||
sendMail | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 13 |
<?php | |
namespace App\Models; | |
use PHPMailer\PHPMailer\PHPMailer; | |
use PHPMailer\PHPMailer\Exception; | |
class Email { | |
private static $instance; | |
public static function getInstance() { | |
if (!self::$instance) { | |
self::$instance = new Email; | |
} | |
return self::$instance; | |
} | |
public function sendMail(){ | |
try { | |
$mail = new PHPMailer(true); | |
$mail->setFrom('test@test.com', 'MyTest'); | |
$mail->addAddress($_SESSION['formularData']['E-Mail'], 'HelloMe'); | |
$mail->isHTML(true); | |
$mail->Subject = 'Vielen Dank für Ihre Bestellung!'; | |
$mail->Body = 'Als nächstes wird ein Twig Template gerendert'; | |
$mail->createBody('../view/orderEmailTemplate.twig', ['name' => $_SESSION['formularData']['Nachname']]); | |
$mail->send(); | |
} catch (Exception $e) { | |
echo 'Die E-Mail konnte nicht versendet werden. Mailer Error: ', $mail->ErrorInfo; | |
} | |
} | |
} |