0

我知道这已经在这里得到了多个答案,但是所有这些答案都没有帮助我解决我的问题。因为它是最简单的测试方法,所以我使用邮件协议,并在我的本地 xampp 机器上工作。这是我的相关代码:

<?php
$this->load->library('email');

$this->email->initialize(array(
    'mailtype' => 'html',
    'validate' => TRUE
);

$this->email->from($this->config->item('demo@example.org', 'Test');
$this->email->to($email);
$this->email->subject('ServerManager Registration');
$this->email->message($mail_content);
if ($this->email->send()) {
    // This becomes triggered when sending
}
?>

变量 $mail_content 和 $email 拼写正确并且可以正常工作。

我在我的 xampp 环境中启用了 mail() 日志记录,因此我可以向您展示触发的日志:

mail() on [C:\xampp\htdocs\core\system\libraries\Email.php:1553]: To: ***@live.de -- Headers: User-Agent: CodeIgniter Date: Thu, 13 Jun 2013 18:14:46 +0200 From: "ServerManager" <your@domain.com> Return-Path: <your@domain.com> Reply-To: "your@domain.com" <your@domain.com> X-Sender: your@domain.com X-Mailer: CodeIgniter X-Priority: 3 (Normal) Message-ID: <51b9eff6ab7bb@domain.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="B_ALT_51b9eff6ab7c2"
4

2 回答 2

0

该问题可能是由于使用$this->config->item. 试试这个

$this->load->library('email');

$this->email->initialize(array(
    'mailtype' => 'html',
    'validate' => TRUE,
));

$this->email->from('demo@example.org', 'Test');
$this->email->to($email);
$this->email->subject('ServerManager Registration');
$this->email->message($mail_content);

if ($this->email->send()) {
    // This becomes triggered when sending
    echo("Mail Sent");
}else{
    echo($this->email->print_debugger()); //Display errors if any
}

PS在您的代码)中,有两个地方丢失了

更新:

通过向GmailYahooRediff 邮件帐户发送邮件来检查脚本localhost。邮件在Gmail中递送(存在于spam文件夹中)。至于YahooRediff 邮件,邮件尚未送达(15 分钟后)到inboxorspam/trash文件夹

于 2013-06-13T17:53:57.487 回答
0
 $this->load->library('email');
 public function mail()
    {
        $config['mailtype'] = 'html';
        $this->email->initialize($config);
        $data = '';
        $email_body = $this->load->view('promo',$data,true);
        $this->email->from('demo@example.org', 'Contact request');          
        $this->email->to('demo.com');
        $this->email->subject('Test');
        $this->email->message($email_body);
        $this->email->send();
        echo $this->email->print_debugger();
    }

试试这个

于 2017-09-08T07:11:46.197 回答