diff options
| author | Carson Fleming <cflems@cflems.net> | 2022-12-12 03:18:01 -0800 |
|---|---|---|
| committer | Carson Fleming <cflems@cflems.net> | 2022-12-12 03:18:01 -0800 |
| commit | 65398eb82a19f3e99085c65630e9df2e3874a089 (patch) | |
| tree | a73977151b738397c09477f81b2c9ae4c5038ee2 /inc/functions.php | |
| parent | 3469db615ee6f8e4a8846de794e4fc66333a142e (diff) | |
| download | bulletin-65398eb82a19f3e99085c65630e9df2e3874a089.tar.gz | |
Add option to send mail with regular mail function instead of mailgun
Diffstat (limited to 'inc/functions.php')
| -rw-r--r-- | inc/functions.php | 27 |
1 files changed, 17 insertions, 10 deletions
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) { |
