1<?php 2class ControllerMailRegister extends Controller { 3 public function index(&$route, &$args, &$output) { 4 $this->load->language('mail/register'); 5 6 $data['text_welcome'] = sprintf($this->language->get('text_welcome'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8')); 7 $data['text_login'] = $this->language->get('text_login'); 8 $data['text_approval'] = $this->language->get('text_approval'); 9 $data['text_service'] = $this->language->get('text_service'); 10 $data['text_thanks'] = $this->language->get('text_thanks'); 11 12 $this->load->model('account/customer_group'); 13 14 if (isset($args[0]['customer_group_id'])) { 15 $customer_group_id = $args[0]['customer_group_id']; 16 } else { 17 $customer_group_id = $this->config->get('config_customer_group_id'); 18 } 19 20 $customer_group_info = $this->model_account_customer_group->getCustomerGroup($customer_group_id); 21 22 if ($customer_group_info) { 23 $data['approval'] = $customer_group_info['approval']; 24 } else { 25 $data['approval'] = ''; 26 } 27 28 $data['login'] = $this->url->link('account/login', '', true); 29 $data['store'] = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'); 30 31 $mail = new Mail($this->config->get('config_mail_engine')); 32 $mail->parameter = $this->config->get('config_mail_parameter'); 33 $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); 34 $mail->smtp_username = $this->config->get('config_mail_smtp_username'); 35 $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); 36 $mail->smtp_port = $this->config->get('config_mail_smtp_port'); 37 $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); 38 39 $mail->setTo($args[0]['email']); 40 $mail->setFrom($this->config->get('config_email')); 41 $mail->setSender(html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8')); 42 $mail->setSubject(sprintf($this->language->get('text_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'))); 43 $mail->setText($this->load->view('mail/register', $data)); 44 $mail->send(); 45 } 46 47 public function alert(&$route, &$args, &$output) { 48 // Send to main admin email if new account email is enabled 49 if (in_array('account', (array)$this->config->get('config_mail_alert'))) { 50 $this->load->language('mail/register'); 51 52 $data['text_signup'] = $this->language->get('text_signup'); 53 $data['text_firstname'] = $this->language->get('text_firstname'); 54 $data['text_lastname'] = $this->language->get('text_lastname'); 55 $data['text_customer_group'] = $this->language->get('text_customer_group'); 56 $data['text_email'] = $this->language->get('text_email'); 57 $data['text_telephone'] = $this->language->get('text_telephone'); 58 59 $data['firstname'] = $args[0]['firstname']; 60 $data['lastname'] = $args[0]['lastname']; 61 62 $this->load->model('account/customer_group'); 63 64 if (isset($args[0]['customer_group_id'])) { 65 $customer_group_id = $args[0]['customer_group_id']; 66 } else { 67 $customer_group_id = $this->config->get('config_customer_group_id'); 68 } 69 70 $customer_group_info = $this->model_account_customer_group->getCustomerGroup($customer_group_id); 71 72 if ($customer_group_info) { 73 $data['customer_group'] = $customer_group_info['name']; 74 } else { 75 $data['customer_group'] = ''; 76 } 77 78 $data['email'] = $args[0]['email']; 79 $data['telephone'] = $args[0]['telephone']; 80 81 $mail = new Mail($this->config->get('config_mail_engine')); 82 $mail->parameter = $this->config->get('config_mail_parameter'); 83 $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); 84 $mail->smtp_username = $this->config->get('config_mail_smtp_username'); 85 $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); 86 $mail->smtp_port = $this->config->get('config_mail_smtp_port'); 87 $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); 88 89 $mail->setTo($this->config->get('config_email')); 90 $mail->setFrom($this->config->get('config_email')); 91 $mail->setSender(html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8')); 92 $mail->setSubject(html_entity_decode($this->language->get('text_new_customer'), ENT_QUOTES, 'UTF-8')); 93 $mail->setText($this->load->view('mail/register_alert', $data)); 94 $mail->send(); 95 96 // Send to additional alert emails if new account email is enabled 97 $emails = explode(',', $this->config->get('config_mail_alert_email')); 98 99 foreach ($emails as $email) { 100 if (utf8_strlen($email) > 0 && filter_var($email, FILTER_VALIDATE_EMAIL)) { 101 $mail->setTo($email); 102 $mail->send(); 103 } 104 } 105 } 106 } 107}