waynemichel Posted September 25, 2012 Share Posted September 25, 2012 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; Quote Link to comment https://forums.phpfreaks.com/topic/268762-add-bcc-email-address-to-function/ Share on other sites More sharing options...
Christian F. Posted September 25, 2012 Share Posted September 25, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/268762-add-bcc-email-address-to-function/#findComment-1380791 Share on other sites More sharing options...
waynemichel Posted September 25, 2012 Author Share Posted September 25, 2012 That was actually as big help. It clued me to go looking for a mail class and I found it and added the bcc. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/268762-add-bcc-email-address-to-function/#findComment-1380914 Share on other sites More sharing options...
Christian F. Posted September 25, 2012 Share Posted September 25, 2012 (edited) You're welcome, and I'm glad to hear that you figured it out. Edited September 25, 2012 by Christian F. Quote Link to comment https://forums.phpfreaks.com/topic/268762-add-bcc-email-address-to-function/#findComment-1380919 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.