2014-09-04 111 views
0

我在codeigniter框架中的电子邮件类存在问题。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 

    <[email protected]>: 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); 

我使用默认配置,所以也许这里是问题?

感谢您的帮助,

+0

某些主机不允许你使用php发送邮件,如果他们的邮件不是从他们的主机发出或发送到field。例如他们想从field到[email protected]。 这里host.com是你的主人。给我更多的细节,如果这没有奏效。 – Zeeshan 2014-09-04 12:02:30

回答

0

它看起来像主机不允许你从标题设置为任何发送电子邮件。尝试使用主机允许的发件人电子邮件(来自标题)。

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

+0

$ this-> email-> from($ headers)不起作用。 $ headers与mail()中的一样。功能 – 2014-09-04 11:46:06

相关问题