Loading... opencart已经历经多个版本更新了,邮件发送问题时常会出现。 整理了一套综合解决方案。 #### 尝试邮箱统一 Settings里,SMTP Username和Store E-Mail设置为相同邮箱 #### 更改代码 Catalog - controller - information - contact.php 找到下面一段 ```php if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $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($this->config->get('config_email')); $mail->setFrom($this->config->get('config_email')); $mail->setReplyTo($this->request->post['email']); $mail->setSender(html_entity_decode($this->request->post['name'], ENT_QUOTES, 'UTF-8')); $mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8')); $mail->setText($this->request->post['enquiry']); $mail->send(); $this->response->redirect($this->url->link('information/contact/success')); } ``` 更改为 ```php if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { // $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'); if(VERSION >= '3.0.0.0') { $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'); } else if(VERSION <= '2.0.1.1') { $mail = new Mail($this->config->get('config_mail')); } else { $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $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($this->config->get('config_email')); $mail->setFrom($this->config->get('config_email')); $mail->setReplyTo($this->request->post['email']); $mail->setSender(html_entity_decode($this->request->post['name'], ENT_QUOTES, 'UTF-8')); $mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8')); $mail->setText($this->request->post['enquiry']); $mail->send(); $this->response->redirect($this->url->link('information/contact/success')); } ``` 更改完后,刷新Modifications缓存 最后修改:2021 年 01 月 22 日 © 允许规范转载 打赏 赞赏作者 支付宝 赞 0 如果觉得我的文章对你有用,请随意赞赏