1

我在 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.
4

1 回答 1

0

你可以试试这个。

在 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;
    }
}
于 2013-06-17T20:31:38.440 回答