php不支持smtp,解决opencart设置SMTP无法发邮件的办法

我们设置好opencart的smtp后,在网站留言处出现错误提示:“Error: MAIL FROM not accepted from server!”

解决有两种方法:

一,修改opencart的邮件发送mail函数,可能主机不支持mail函数。修改麻烦,放弃!

二:发件人是自己,修改opencart本身的php文件,用户填写的邮箱通过邮件传送代码即可。

具体修改文件“contact.php”即可.

打开这个文件,找到如下代码:

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {

$mail = new Mail();

$mail->protocol = $this->config->get('config_mail_protocol');

$mail->parameter = $this->config->get('config_mail_parameter');

$mail->hostname = $this->config->get('config_smtp_host');

$mail->username = $this->config->get('config_smtp_username');

$mail->password = $this->config->get('config_smtp_password');

$mail->port = $this->config->get('config_smtp_port');

$mail->timeout = $this->config->get('config_smtp_timeout');

$mail->setTo($this->config->get('config_email'));

$mail->setFrom($this->request->post['email']);

//www.zuimoban.com

$mail->setSender($this->request->post['name']);

$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));

$mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry'], ENT_QUOTES, 'UTF-8')));

$mail->send();

$this->redirect($this->url->link('information/contact/success'));

}

这里POST参数:email、name 和 enquiry ,对应的是用户填写的邮件地址、名字和邮件内容。

//收件人

$mail->setTo($this->config->get('config_email'));

//发件人

$mail->setFrom($this->request->post['email']);

修改为:

//收件人

$mail->setTo($this->config->get('config_email'));

//发件人

$mail->setFrom($this->config->get('config_email'));

//收件人名称修改

$mail->setSender($this->request->post['name']);

//修改为:

$mail->setSender($this->request->post['name'].'request->post['email'].'>');

这里定义发件人邮箱地址。

会出现报错:“Error: RCPT TO not accepted from server!”,

解决办法:

//收件人

$mail->setTo($this->config->get('config_email'));

//改为自己定义的:

$mail->setTo('你的邮箱地址');

问题解决.

(责任编辑:最模板)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值