diff --git a/classes/core.php b/classes/core.php index 0ae428968..403b5e8b8 100755 --- a/classes/core.php +++ b/classes/core.php @@ -1137,13 +1137,25 @@ public static function send_auto_response($config, $form) if (!empty($config['bcc'])) { $email_message['bcc'] = Caldera_Forms::do_magic_tags($config['bcc']); - $bcc_array = array_map('trim', preg_split('/[;,]/', Caldera_Forms::do_magic_tags($config['bcc']))); + $bcc_array = array_map('trim', preg_split('/[;,]/', Caldera_Forms::do_magic_tags($config['bcc']))); foreach ($bcc_array as $bcc_to) { if (is_email($bcc_to)) { $email_message['headers'][] = 'Bcc: ' . $bcc_to; } } - } + } + + $email_message['cc'] = false; + if (!empty($config['cc'])) { + $email_message['cc'] = Caldera_Forms::do_magic_tags($config['cc']); + + $cc_array = array_map('trim', preg_split('/[;,]/', Caldera_Forms::do_magic_tags($config['cc']))); + foreach ($cc_array as $cc_to) { + if (is_email($cc_to)) { + $email_message['headers'][] = 'Cc: ' . $cc_to; + } + } + } /** * Filter email to be sent as auto responder diff --git a/classes/email/sendgrid.php b/classes/email/sendgrid.php index 2c519c6f7..43b75da32 100755 --- a/classes/email/sendgrid.php +++ b/classes/email/sendgrid.php @@ -93,13 +93,20 @@ public function send(){ } } - if( ! empty( $this->message[ 'bcc' ] ) && is_email( $this->message[ 'bcc' ] ) ){ + if( ! empty( $this->message[ 'bcc' ] ) && is_email( $this->message[ 'bcc' ] ) ){ $email = $this->create_email( $this->message[ 'bcc' ] ); if ( is_object( $email ) ) { $personalization->addTo( $email ); } } + + if( ! empty( $this->message[ 'cc' ] ) && is_email( $this->message[ 'cc' ] ) ){ + $email = $this->create_email( $this->message[ 'cc' ] ); + if ( is_object( $email ) ) { + $personalization->addTo( $email ); + } + } $mail->addPersonalization( $personalization ); diff --git a/classes/email/sendgrid/lib/helpers/mail/Mail.php b/classes/email/sendgrid/lib/helpers/mail/Mail.php index 8d176b519..b7cfb607b 100755 --- a/classes/email/sendgrid/lib/helpers/mail/Mail.php +++ b/classes/email/sendgrid/lib/helpers/mail/Mail.php @@ -79,6 +79,43 @@ public function jsonSerialize() } } +class CcSettings implements \jsonSerializable +{ + private + $enable, + $email; + + public function setEnable($enable) + { + $this->enable = $enable; + } + + public function getEnable() + { + return $this->enable; + } + + public function setEmail($email) + { + $this->email = $email; + } + + public function getEmail() + { + return $this->email; + } + + public function jsonSerialize() + { + return array_filter( + [ + 'enable' => $this->getEnable(), + 'email' => $this->getEmail() + ] + ); + } +} + class OpenTracking implements \jsonSerializable { private @@ -511,6 +548,7 @@ class MailSettings implements \jsonSerializable { private $bcc, + $cc, $bypass_list_management, $footer, $sandbox_mode, @@ -525,6 +563,16 @@ public function getBccSettings() { return $this->bcc; } + + public function setCcSettings($cc) + { + $this->cc = $cc; + } + + public function getCcSettings() + { + return $this->cc; + } public function setBypassListManagement($bypass_list_management) { diff --git a/classes/save.php b/classes/save.php index be4939ee2..85a2dce68 100644 --- a/classes/save.php +++ b/classes/save.php @@ -203,8 +203,20 @@ public static function do_mailer( $form, $entryid = null, $data = null, array $s 'attachments' => array() ); $mail['from'] = $sendermail; - $mail['from_name'] = $sendername; - + $mail['from_name'] = $sendername; + + // if added a cc + $mail['cc'] = false; + if ( isset( $form['mailer']['cc_to'] ) && ! empty( $form['mailer']['cc_to'] ) ) { + $mail['cc'] = $form['mailer']['cc_to']; + + $cc_array = array_map('trim', preg_split( '/[;,]/', Caldera_Forms::do_magic_tags( $form['mailer']['cc_to'] ) ) ); + foreach( $cc_array as $cc_to ) { + if ( is_email( $cc_to ) ) { + $mail['headers'][] = 'Cc: ' . $cc_to; + } + } + } // if added a bcc $mail['bcc'] = false; diff --git a/ui/panels/emailer.php b/ui/panels/emailer.php index 9c4711504..e6d84d12d 100755 --- a/ui/panels/emailer.php +++ b/ui/panels/emailer.php @@ -126,7 +126,20 @@ -
+ +
+ +
+ +

+ +

+
+
+ +