G
G
gladislav992020-11-11 14:48:01
opencart
gladislav99, 2020-11-11 14:48:01

How to send a letter to the admin with a substitute e-mail of the sender for the e-mail of the buyer?

Good afternoon, I'm struggling with such a task. How to implement so that letters to the admin about orders come with the substitution of the sender's email for the buyer's email. That is, what would a person order with email - [email protected] and it was he who was the sender of the letter to the admin, and not the store's mail. OpenCart 3
Found these lines in mail/order.php

$this->load->model('setting/setting');
    
    $from = $this->model_setting_setting->getSettingValue('config_email', $order_info['store_id']);
    
    if (!$from) {
      $from = $this->config->get('config_email');
    }
    
    $mail = new Mail($this->config->get('config_mail_engine'));
    $mail->parameter = $this->config->get('config_mail_parameter');
    $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
    $mail->smtp_username = $this->config->get('config_mail_smtp_username');
    $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
    $mail->smtp_port = $this->config->get('config_mail_smtp_port');
    $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');

    $mail->setTo($order_info['email']);
    $mail->setFrom($from);
    $mail->setSender(html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'));
    $mail->setSubject(html_entity_decode(sprintf($language->get('text_subject'), $order_info['store_name'], $order_info['order_id']), ENT_QUOTES, 'UTF-8'));
    $mail->setHtml($this->load->view('mail/order_add', $data));
    $mail->send();
  }


Here, as I understand it, an e-mail is formed for sending messages ( 'config_email') but I don’t fully understand how to change it to the user’s e-mail variable ($order_info['email']).
I would appreciate any help, thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
web-mechanic, 2020-11-12
@gladislav99

- change here $mail->setFrom( $from );
but keep in mind that the mail service may not let such letters through in some cases, considering them to be spam

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question