【问题标题】:Email class in CodeIgniterCodeIgniter 中的电子邮件类
【发布时间】: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


【解决方案1】:

看起来主机不允许您发送带有 from 标头设置的电子邮件。尝试使用主机允许的发件人电子邮件(发件人标头)。

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

【讨论】:

  • $this->email->from($headers) 不起作用。 $headers 与 mail(); 中的相同。功能
猜你喜欢
  • 2013-08-02
  • 2017-12-07
  • 1970-01-01
  • 1970-01-01
  • 2018-08-06
  • 2016-05-27
  • 2012-03-22
  • 1970-01-01
  • 2015-10-08
相关资源
最近更新 更多