【问题标题】:Codeigniter email issue with gmailgmail的Codeigniter电子邮件问题
【发布时间】:2015-03-15 13:48:39
【问题描述】:

这是我的代码:

$this->email->from('your@example.com', 'Your Name');
$this->email->to('myemail@gmail.com');
$this->email->cc('myemail2@gmail.com');

$this->email->subject('Email Test');
$this->email->message('Testing the email class.');

$this->email->send();
echo $this->email->print_debugger();

这是回显的结果:

Your message has been successfully sent using the following protocol: mail

From: "Your Name" <your@example.com>
Return-Path: <your@example.com>
Cc: myemail2@gmail.com
Reply-To: "your@example.com" <your@example.com>
X-Sender: your@example.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <55058c9e98942@example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
=?utf-8?Q?Email_Test?=
Testing the email class.

我正在测试一个联系表。第一次尝试我收到了这条消息,即使我在gmail帐户"This message may not have been sent by: myemail@gmail.com"收到这条消息

我尝试使用 php 的邮件功能:

$to = "myemail@gmail.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com" . "\r\n" .
"CC: myemail2@gmail.com";

但我没有收到任何电子邮件。我应该怎么办 ?我做错了什么?

更新:

        $config['protocol'] = 'sendmail';
        $config['charset'] = 'iso-8859-1';
        $config['wordwrap'] = TRUE;
        $config['priority'] = 1;

        $this->email->initialize($config);
        $this->email->from('your@example.com', 'Your Name');
        $this->email->to('cazare.carei.strand@gmail.com');
        $this->email->cc('naghi.attila@gmail.com');

        $this->email->subject('Email Test');
        $this->email->message('Testing the email class.'); 

        $this->email->send();
        echo $this->email->print_debugger(); exit();

【问题讨论】:

    标签: php codeigniter email


    【解决方案1】:

    如果您的端口 25 已打开,则电子邮件应该可以发送。一些电子邮件提供商要求在来自发件人的电子邮件域的 DNS 记录中设置有效的mx record,以禁止发送未经授权的发件人的虚假电子邮件。

    我不确定gmail是否有这个要求。

    如果您想解决这个问题,您可以重新配置 example.com 的 DNS 条目以包含您的服务器的 IP 地址。另一种可能性是使用外部 smtp 服务器而不是服务器的内部 sendmail 发送电子邮件。我的经验是这可能很慢(在一个大的 webabbplication 上)。

    作为found on google,您可以在邮件配置中使用codignither作为协议条目:'sendmail'。

    编辑:

    “此邮件可能不是由发送的:myemail@gmail.com”

    这可能表明 Google 不信任发送服务器。

    【讨论】:

    • 我不是从本地机器发送的。我把邮箱改成了雅虎账号,但都没有收到任何消息
    • 您的非本地机器必须在 example.com 的 dns-entries 中有它的 ip。你可以尝试给我发电子邮件。 jakob -dot-eichler [at] altergear -dot-net 因为我的服务器不再检查有效的 mx 记录。在你发送邮件后在这里告诉我,这样我就可以删除我的电子邮件地址。即使域的 A 记录指向邮件服务器,您的 mx 记录也应该正确设置。
    • 请在我的帖子中查看我的更新。我仍然没有收到任何电子邮件:(
    • 这真的很奇怪,首先它可以工作,但是当我用我的数据更改主题、来自和消息时,它没有工作;之后我把它放回去了,但它不起作用跨度>
    • 您是否尝试给我发送电子邮件。根据我的理论,“来自”才是最重要的。
    猜你喜欢
    • 2011-08-13
    • 2014-01-24
    • 2013-01-21
    • 2016-08-12
    • 2011-03-03
    • 1970-01-01
    • 2011-10-28
    • 2018-12-08
    • 2021-03-26
    相关资源
    最近更新 更多