From b8315263ec334399356079f3830529fc0160478b Mon Sep 17 00:00:00 2001 From: Anthony Bourguignon Date: Wed, 4 Jan 2023 18:04:37 +0100 Subject: [PATCH] switch to phpmailer to send emails --- src/form/contact-form-handler.php | 49 +++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/src/form/contact-form-handler.php b/src/form/contact-form-handler.php index 4c1cb29..bcb2a54 100644 --- a/src/form/contact-form-handler.php +++ b/src/form/contact-form-handler.php @@ -1,6 +1,12 @@ ", $emailBody); - // send the email - mail($to, $emailSubject, $emailBodyHTML, implode("\r\n", $headers)); + $mail->isSMTP(); + $mail->Host = getenv('ASTRO_SMTP_HOSTNAME'); + $mail->SMTPAuth = true; + $mail->Username = getenv('ASTRO_SMTP_USERNAME'); + $mail->Password = getenv('ASTRO_SMTP_PASSWORD'); + $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; + $mail->Port = 587; + + //Options + $mail->CharSet = 'UTF-8'; + $mail->WordWrap = 70; + + //Recipients + $mail->setFrom($myEmail); + //$mail->addAddress($myEmail); + $mail->addAddress('anthony@6clones.fr'); + $mail->addReplyTo($emailAddress, $name); + + // Content + $mail->isHTML(true); + $mail->Subject = $emailSubject; + $mail->Body = $emailBodyHTML; + $mail->AltBody = $emailBody; + + $mail->send(); // if subscribe add to mailing list if(!empty($subscribe)) {