2014-09-04 44 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

相關問題