【发布时间】:2014-09-04 11:17:14
【问题描述】:
我对 codeigniter 框架中的电子邮件类有疑问。
$email = (string)$this->input->post('email');
$name = (string)$this->input->post('name');
$text = (string)$this->input->post('text');
$to = "my mail address";
$title = "Title";
$this->email->from($email, $name);
$this->email->to($to);
$this->email->subject($title);
$this->email->message($text);
$this->email->send();
它不起作用。当我尝试发送电子邮件时,我会在我的电子邮件中收到此消息。
This is the mail system at host postlady.000webhost.com.
I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.
For further assistance, please send mail to postmaster.
If you do so, please include this problem report. You can
delete your own text from the attached returned message.
The mail system
<g-o-g-u@tlen.pl>: host mx13.o2.pl[193.17.41.15] said: 550 Bad SPF records
for
[tlen.pl:31.170.163.248],
经典 PHP 函数 mail($to, $title, $msg, $headers);效果很好。
也许我应该配置这个类?
$config['protocol'] = 'mail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'UTF-8';
$config['wordwrap'] = TRUE;
$this->email->initialize($config);
我使用默认配置,所以可能是这里的问题?
谢谢你的帮助,
【问题讨论】:
-
如果他们的邮件不是来自他们的主机,在 from 或 to 字段中,某些主机不允许您使用 php 发送邮件。例如,他们希望 from 字段为 something@host.com。这里 host.com 是您的主机。如果这不起作用,请给我更多详细信息。
标签: php codeigniter email