/** send email to store owner */ private function _notify_store_admin($merchant_details, $notification, $settings, $emailTemplate) { /** * send email to store owner */ $from = array($settings['email_from'] => $settings['company']); if ($this->_test_violator_notifications) { $to = '*****@*****.**'; } else { $to = array($settings['email_from']); } $searches = array('#SellerName', '#CompanyName', '#ContactName', '#Phone', '#NameTo', '#EmailTo', '#Date', '#Evidence'); $replacements = array($this->data->merchant, $settings['company'], $settings['name_from'], $settings['phone'], $settings['name_to'], $settings['email_to'], date('m/d/Y'), $this->_get_evidence_table()); $html = str_replace($searches, $replacements, $emailTemplate['unknown_seller_html_body']); $text = $this->_get_text_from_html_contents($html); try { send_smtp($this->smtp, $to, $this->data->subject, $html, $text, $from, $this->data->attachment); } catch (phpmailerException $e) { log_message('error', 'phpMailerException sending admin notification for store ' . $settings['store_id'] . ' to ' . $settings['email_to'] . ' from ' . $settings['email_from'] . ': ' . $e->getMessage()); } }
/** * Used to test SMTP setting entered in by user. * * @author unknown * @todo finish this function (this is just copied and pasted from elsewhere, so need variables changed, and return status) * @todo move to library function * @param array $smtp_settings */ public function send_test_email($smtp_settings) { $this->load->library('Vision_users'); $smtpInfo = array('host' => $smtp_settings['smtp_host'], 'port' => $smtp_settings['smtp_port'], 'use_ssl' => $smtp_settings['smtp_ssl'], 'use_tls' => $smtp_settings['smtp_tls'], 'username' => $smtp_settings['smtp_username'], 'password' => $smtp_settings['smtp_password']); $this->load->library('SMTP_auth', $smtpInfo, 'smtp'); $to = $from = $smtp_settings['email_from']; $support_team_error_msg = ''; if (empty($this->data->error)) { $this->data->error = ''; } try { send_smtp($this->smtp, $to, "SMTP Test E-mail from TrackStreet", "<div>This is a test email that was successfully sent to you as a result of the SMTP settings you entered with TrackStreet.</div>", "This is a test email that was successfully sent to you as a result of the SMTP settings you entered with TrackStreet.", $from, FALSE); } catch (phpmailerException $e) { $this->data->error .= "SMTP settings entered are not valid. Please review. Also, support team was notified and will be in touch to help."; $support_team_error_msg .= $e->getMessage(); //return; } catch (Exception $e) { $this->data->error .= "SMTP settings entered are not valid. Please review. Also, support team was notified and will be in touch to help."; $support_team_error_msg .= $e->getMessage(); //return; } if ($support_team_error_msg == '') { $this->data->message .= "SMTP settings look good and test email was successfully sent to you!"; } else { // send notification to TrackStreet staff about store being added $email = $this->config->item('environment') == 'production' ? 'christophe@trackstreet.com, chris@trackstreet.com' : '*****@*****.**'; $subject = '[TrackStreet] Error with SMTP Settings for Store: ' . $from; $html_message = "<p>Check on SMTP for: {$from}</p>"; $html_message .= "<p>User who added store: {$this->user['first_name']} {$this->user['last_name']} (ID: {$this->user_id})</p>"; $html_message .= "<p>Error:</p>"; $html_message .= "<p>{$support_team_error_msg}</p>"; $text_message = strip_tags($html_message); $this->vision_users->sendSESEmail($email, $subject, $html_message, $text_message); } return; }