Jump to content

Add Bcc Email Address To Function


waynemichel

Recommended Posts

I have a script to schedule appointments and there is a facility to resend a confirmation email. How can I add a bcc email to this function (hardcoded email) so I get copy.

 

function reSend()
{
$this->isAjax = true;

if ($this->isXHR())
{
Object::import('Model', 'Booking');
$BookingModel = new BookingModel();

if (isset($_POST['message']))
{
$booking_arr = $BookingModel->get($_POST['id']);

Object::import('Component', 'Email');
$Email = new Email();
$Email->send($booking_arr['customer_email'], $this->option_arr['email_confirmation_subject'], $_POST['message'], $this->option_arr['email_address']);

header("Content-type: text/json");
echo '{"code":200}';
exit;
} else {
$booking_arr = $BookingModel->get($_GET['id']);

$country = NULL;
if (!empty($booking_arr['customer_country']))
{
 Object::import('Model', 'Country');
 $CountryModel = new CountryModel();
 $country_arr = $CountryModel->get($booking_arr['customer_country']);
 if (count($country_arr) > 0)
 {
 $country = $country_arr['country_title'];
 }
}

if (count($booking_arr) > 0)
{
 Object::import('Model', array('BookingDetail', 'Service'));
 $BookingDetailModel = new BookingDetailModel();
 $ServiceModel = new ServiceModel();
 $BookingDetailModel->addJoin($BookingDetailModel->joins, $ServiceModel->getTable(), 'TS', array('TS.id' => 't1.service_id'), array('TS.name.service_name'));
 $booking_arr['details_arr'] = $BookingDetailModel->getAll(array('t1.booking_id' => $booking_arr['id']));
}

$row = array();
foreach ($booking_arr['details_arr'] as $v)
{
 $cell = stripslashes($v['service_name']) . ": ".
 date($this->option_arr['date_format'], strtotime($v['date'])). ", ".
 date($this->option_arr['time_format'], $v['start_ts']). " - ".
 date($this->option_arr['time_format'], $v['start_ts'] + $v['total'] * 60);
 $row[] = $cell;
}
$booking_data = count($row) > 0 ? join("\n", $row) : NULL;

$cancelURL = INSTALL_URL . 'index.php?controller=Front&action=cancel&cid='.$booking_arr['calendar_id'].'&id='.$booking_arr['id'].'&hash='.sha1($booking_arr['id'].$booking_arr['created'].$this->salt);
$search = array('{Name}', '{Email}', '{Phone}', '{Country}', '{City}', '{State}', '{Zip}', '{Address}', '{Notes}', '{CCType}', '{CCNum}', '{CCExp}', '{CCSec}', '{PaymentMethod}', '{PaymentOption}', '{Deposit}', '{Total}', '{Tax}', '{BookingID}', '{Services}', '{CancelURL}');
$replace = array($booking_arr['customer_name'], $booking_arr['customer_email'], $booking_arr['customer_phone'], $country, $booking_arr['customer_city'], $booking_arr['customer_state'], $booking_arr['customer_zip'], $booking_arr['customer_address'], $booking_arr['customer_notes'], $booking_arr['cc_type'], $booking_arr['cc_num'], ($booking_arr['payment_method'] == 'creditcard' ? $booking_arr['cc_exp'] : NULL), $booking_arr['cc_code'], $booking_arr['payment_method'], $booking_arr['payment_option'], $booking_arr['booking_deposit'] . " " . $this->option_arr['currency'], $booking_arr['booking_total'] . " " . $this->option_arr['currency'], $booking_arr['booking_tax'] . " " . $this->option_arr['currency'], $booking_arr['id'], $booking_data, $cancelURL);

$message = str_replace($search, $replace, $this->option_arr['email_confirmation_message']);

$this->tpl['message'] = $message;
}
}
}

 

I believe it can be added here (maybe?):

 

$Email = new Email();
$Email->send($booking_arr['customer_email'], $this->option_arr['email_confirmation_subject'], $_POST['message'], $this->option_arr['email_address']);

header("Content-type: text/json");
echo '{"code":200}';
exit;

Link to comment
https://forums.phpfreaks.com/topic/268762-add-bcc-email-address-to-function/
Share on other sites

You have to look in the Email class that you're using, and see if you can find a "BCC" method (or how to add headers manually).

Since you've posted no details about what kind of system you're using, I'm unable to give you any further help on this.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.