From c13d06eccb5127c932e53bc0bbda33810c871d0c Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Wed, 21 Oct 2020 12:06:42 +0200 Subject: [PATCH] Use PHPMailer in sending email bug reports --- MDErrorReporter.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/MDErrorReporter.php b/MDErrorReporter.php index e2df86a..e6c1385 100644 --- a/MDErrorReporter.php +++ b/MDErrorReporter.php @@ -191,16 +191,17 @@ final class MDErrorReporter { $msg .= PHP_EOL . PHP_EOL; - $msg = shell_exec("echo " . escapeshellarg($msg) . " | gpg2 --always-trust --recipient " . escapeshellarg($to) . " --encrypt --armor --local-user 35CA0E31F6F44FB5 --sign"); + $msg = MDMailerHelper::pgp_encrypt($to, $msg); - // Set header - $header = [ - 'From' => $this->_contact_mail_addr, - 'X-Mailer' => 'PHP/' . phpversion() - ]; + $mail = MDMailerHelper::setup_PHPMailer(); + $mail->setFrom($this->_contact_mail_addr, $this->_contact_mail_addr); + $mail->addAddress($to); + $mail->addReplyTo(MD_CONF_EMAIL::SMTP_REPLY_TO_ERROR); + $mail->isHTML(false); + $mail->Subject = $subject; + $mail->Body = "$msg"; - // Send email - mail("$to", "$subject", "$msg", $header); + $mail->send(); }