Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions classes/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion classes/email/sendgrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
48 changes: 48 additions & 0 deletions classes/email/sendgrid/lib/helpers/mail/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -511,6 +548,7 @@ class MailSettings implements \jsonSerializable
{
private
$bcc,
$cc,
$bypass_list_management,
$footer,
$sandbox_mode,
Expand All @@ -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)
{
Expand Down
16 changes: 14 additions & 2 deletions classes/save.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 14 additions & 1 deletion ui/panels/emailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,20 @@
</div>

</div>
<div class="caldera-config-group">

<div class="caldera-config-group">
<label for="cf-email-cc">
<?php esc_html_e('CC', 'caldera-forms'); ?>
</label>
<div class="caldera-config-field">
<input type="text" class="field-config magic-tag-enabled" name="config[mailer][cc_to]" value="<?php if(isset( $element['mailer']['cc_to'] ) ){ echo $element['mailer']['cc_to']; } ?>" style="width:400px;" id="cf-email-cc" aria-describedby="cf-email-cc-description" />
<p class="description" id="cf-email-cc-description">
<?php esc_html_e('Comma separated list of email addresses to send a CC to.', 'caldera-forms'); ?>
</p>
</div>
</div>

<div class="caldera-config-group">
<label for="cf-email-bcc">
<?php esc_html_e('BCC', 'caldera-forms'); ?>
</label>
Expand Down