【问题标题】:Why don't I receive an email using codeigniter email library when using local server?为什么我在使用本地服务器时收不到使用 codeigniter 电子邮件库的电子邮件?
【发布时间】:2013-02-03 11:23:09
【问题描述】:

我在 mac os x apache 2 服务器上使用 codeigniter 的电子邮件库。我遇到的奇怪的事情是,当我在 hostgator.com 上的实时服务器上使用它时,电子邮件会通过,但是当我在本地 apache2 服务器上运行相同的代码时,我没有收到任何电子邮件(即使在垃圾邮件箱中) )。可能是什么问题?这是代码

        $this->load->library('email');
        $this->email->from('your@example.com', 'Your Name');
        $this->email->to('myemailhere@gmail.com'); 
        $this->email->subject('Email Test');
        $this->email->message('Testing the email class.');  
        if($this->email->send())
        {    
            var_export($this->email->print_debugger());
        }

在本地和实时服务器上,这是 var_dump 数据

'Your message has been successfully sent using the following protocol: mail
From: "Your Name" 
Return-Path: 
Reply-To: "your@example.com" 
X-Sender: your@example.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <5122a6ed242b8@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.

【问题讨论】:

  • 您的本地 apache 服务器必须设置为发送真实电子邮件。
  • 你有这个教程的链接吗?
  • 要让@RocketHazmat 回答,您必须向我们提供有关您当地环境的更多信息。你是在 Windows/Mac/Linux 上开发吗?
  • 是的,我在 Mac 上。 10.7.5

标签: macos codeigniter localhost email


【解决方案1】:

你可以试试这个。

在php.ini中指定发送邮件的路径

sendmail_path = "path/to/php path/to/sendmail.php"

第二步——你可以尝试使用这个脚本

define('DIR','path/to/sendmail_dir');
$stream = '';
$fp = fopen('php://stdin','r');
while ($t = fread($fp,2048)) {
    if ($t === chr(0)) {
        break;
    }
    $stream .= $t;
}
fclose($fp);

$fp = fopen(mkname(),'w');
fwrite($fp,$stream);
fclose($fp);

function mkname($i = 0) {
    $fn = DIR.date('Y-m-d_H-i-s_').$i.'.eml';
    if (file_exists($fn)) {
        return mkname(++$i);
    } else {
        return $fn;
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-05
    • 2022-11-18
    • 2015-09-06
    • 2018-12-10
    • 2018-04-29
    • 2011-09-24
    • 2017-12-07
    • 2012-12-29
    相关资源
    最近更新 更多