From 65398eb82a19f3e99085c65630e9df2e3874a089 Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Mon, 12 Dec 2022 03:18:01 -0800 Subject: Add option to send mail with regular mail function instead of mailgun --- inc/functions.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index 34b74aa..4bd37af 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -75,17 +75,24 @@ function bulletin_hash ($str, $salt = '') { function bulletin_mail ($to, $subject, $body) { global $b_config; - try { - $mg = new Mailgun\Mailgun($b_config['mg_key']); - return $mg->sendMessage($b_config['mg_dom'], array( - 'from' => $b_config['mail_from'], - 'to' => $to, - 'subject' => $subject, - 'html' => $body, - )); - } catch (Exception $e) { - return 0; + if (isset($b_config['mg_key'])) { + try { + $mg = new Mailgun\Mailgun($b_config['mg_key']); + return $mg->sendMessage($b_config['mg_dom'], array( + 'from' => $b_config['mail_from'], + 'to' => $to, + 'subject' => $subject, + 'html' => $body, + )); + } catch (Exception $e) { + return 0; + } } + //$headers = 'To: ' . $to . "\r\n"; + $headers = 'From: ' . $b_config['mail_from'] . "\r\n"; + $headers .= 'MIME-Version: 1.0' . "\r\n"; + $headers .= 'Content-type: text/html; charset=utf-8' + return mail($to, $subject, $body, $headers); } function pwgen ($len) { -- cgit v1.2.3