Optionally CC and BCC all mails
Change-Id: Ic7a4b0c1af6ae3598f925a3b6abb6d7db11f26c7
diff --git a/config.php.example b/config.php.example
index bbe9a9f..db94b43 100755
--- a/config.php.example
+++ b/config.php.example
@@ -33,6 +33,8 @@
'username' => 'signup@gmail.com',
'password' => 'xxxxxxxxxx'
];
+// $MAIL_CC = "ccme@example.org"; // optionally CC all mails
+// $MAIL_BCC = "bccme@example.org"; // optionally BCC all mails
// User Validation
$VAL_USER = (object)[
diff --git a/mail.php b/mail.php
index 9c69255..1432a26 100755
--- a/mail.php
+++ b/mail.php
@@ -4,6 +4,8 @@
include 'config.php';
function send_mail(string $email, object $smtp, object $message) {
+ include 'config.php';
+
$crlf = "\r\n";
$headers = array(
@@ -12,6 +14,15 @@
'Subject' => $message->subject
);
+ if (isset($CC_MAIL)) {
+ $headers['Cc'] = $CC_MAIL;
+ $email .= ', ' . $CC_MAIL;
+ }
+
+ if (isset($BCC_MAIL)) {
+ $email .= ', ' . $BCC_MAIL;
+ }
+
$smtp = Mail::factory('smtp', array(
'host' => $smtp->host,
'port' => $smtp->port,