Compare commits

..

2 Commits

Author SHA1 Message Date
7bf2701865 Fix price mismatch 2026-03-03 14:34:03 -07:00
f45a2a1acb Add reply-to on email receipt 2025-11-08 13:37:36 -07:00
3 changed files with 30 additions and 7 deletions

View File

@ -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);
}

View File

@ -14,12 +14,7 @@ try {
if ($rate->id == $_REQUEST["rateid"]) {
$cost = $rate->rate;
$retail_rate = $rate->retail_rate ?? ($rate->list_rate ?? $rate->rate);
if ($retail_rate - $cost > 3) {
// Cap at $3 profit to be nice
$price = $cost + 3.00;
} else {
$price = $cost + 1.00;
}
$price = $retail_rate + 1.00;
}
}
@ -192,6 +187,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";

View File

@ -9,6 +9,7 @@ $_SETTINGS = [
"server" => "mail.netsyms.net",
"port" => 587,
"user" => "noreply@netsyms.com",
"replyto" => "reply@netsyms.com",
"password" => "",
"security" => "tls"
],