diff --git a/source/static/lib/email.lib.php b/source/static/lib/email.lib.php index 9b79591..162c1f4 100644 --- a/source/static/lib/email.lib.php +++ b/source/static/lib/email.lib.php @@ -7,6 +7,7 @@ class Email { private $subject = ""; private $body = ""; + private $html = ""; private $attachments = []; private $to = []; private $fromaddress = ""; @@ -17,6 +18,7 @@ class Email { private $smtpusername = ""; private $smtppassword = ""; private $smtpsecurity = ""; + private $replyto = ""; public function setFrom(string $address, string $name = "") { $this->fromaddress = $address; @@ -35,10 +37,18 @@ class Email { $this->body = $body; } + public function setHtmlBody(string $html) { + $this->html = $html; + } + public function addAttachment(string $filename, string $name = "") { $this->attachments[$filename] = $name; } + public function setReplyTo(string $em) { + $this->replyto = $em; + } + public function addTo(string $email) { $this->to[] = $email; } @@ -79,10 +89,24 @@ class Email { $mail->SMTPSecure = $this->smtpsecurity; } $mail->Port = $this->smtpport; - $mail->isHTML(false); + + if (empty($this->html)) { + $mail->isHTML(false); + $mail->CharSet = "text/plain; charset=UTF-8;"; + $mail->Body = $this->body; + } else { + $mail->isHTML(true); + $mail->CharSet = "text/html; charset=UTF-8;"; + $mail->Body = $this->html; + $mail->AltBody = $this->body; + } $mail->setFrom($this->fromaddress, $this->fromname); + if (!empty($this->replyto)) { + $mail->addReplyTo($this->replyto); + } + foreach ($this->to as $to) { $mail->addAddress($to); } diff --git a/source/static/payshipment.php b/source/static/payshipment.php index 0a65f03..20da8e7 100644 --- a/source/static/payshipment.php +++ b/source/static/payshipment.php @@ -192,6 +192,9 @@ try { $emailsettings = $_SETTINGS["email"]; $mail->setSMTP($emailsettings["server"], $emailsettings["port"], true, $emailsettings["user"], $emailsettings["password"], $emailsettings["security"]); $mail->setFrom($emailsettings["user"], "CertifiedFromHome.com"); + if (!empty($emailsettings["replyto"])) { + $mail->setReplyTo($emailsettings["replyto"]); + } $mail->addTo($shipment->from_address->email); $mail->setSubject("Your CertifiedFromHome Receipt"); $body = "Thanks for using CertifiedFromHome.com!\r\nYour card has been charged a total of $" . number_format($price, 2) . ".\r\n"; diff --git a/source/static/settings.sample.php b/source/static/settings.sample.php index a70c8db..66c3a69 100644 --- a/source/static/settings.sample.php +++ b/source/static/settings.sample.php @@ -9,6 +9,7 @@ $_SETTINGS = [ "server" => "mail.netsyms.net", "port" => 587, "user" => "noreply@netsyms.com", + "replyto" => "reply@netsyms.com", "password" => "", "security" => "tls" ],