CodeIgniter中的电子邮件类

时间:2014-09-04 11:17:14

标签: php codeigniter email

我在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函数邮件($ to,$ title,$ msg,$ headers);效果很好。

也许我应该配置这个课程?

$config['protocol'] = 'mail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'UTF-8';
$config['wordwrap'] = TRUE;

$this->email->initialize($config);

我使用默认配置,所以这可能是问题吗?

感谢您的帮助,

1 个答案:

答案 0 :(得分:0)

主机似乎不允许您将标头设置为任何内容发送电子邮件。尝试使用主机允许的发件人电子邮件(From标头)。

当您使用mail()进行测试时,您可能正在使用它。