显示'发送的电子邮件'但我的收件箱中没有任何内容。 CodeIgniter和gmail

时间:2012-06-25 15:47:02

标签: codeigniter smtp gmail

请检查我的以下代码,以便从我的Gmail帐户向同一个Gmail帐户发送电子邮件。当我运行它时,它说电子邮件已发送。但我在收件箱中找不到任何此类内容。任何人都可以提出问题所在吗?

$config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.googlemail.com',
        'smtp_port' => 465,
        'smtp_user' => 'koolpraju@gmail.com',
        'smtp_password' => '****',
        'mailtype' => 'html',
        'charset' => 'iso-8859-1'
    );

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


    $this->email->set_newline("\r\n");

    $this->email->from('koolpraju@gmail.com','Prajakta');
    $this->email->to('koolpraju@gmail.com');
    $this->email->subject('This is a test email');
    $this->email->message('It is working. Great!! yey');

    if($this->email->send())
    {
        echo 'Your email was sent successfully';

    }
    else
    {
        show_error($this->email->print_debugger());
    }

我让Xampp与Mercury一起运行并设置了Mercury S SMTP Server参数。我真的不明白为什么电子邮件没有通过?有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

function sendMail()
{
    $config = Array(
  'protocol' => 'smtp',
  'smtp_host' => 'ssl://smtp.googlemail.com',
  'smtp_port' => 465,
  'smtp_user' => 'xxx@gmail.com', // change it to yours
  'smtp_pass' => 'xxx', // change it to yours
  'mailtype' => 'html',
  'charset' => 'iso-8859-1',
  'wordwrap' => TRUE
);

        $message = '';
        $this->load->library('email', $config);
      $this->email->set_newline("\r\n");
      $this->email->from('xxx@gmail.com'); // change it to yours
      $this->email->to('xxx@gmail.com');// change it to yours
      $this->email->subject('Resume from JobsBuddy for your Job posting');
      $this->email->message($message);
      if($this->email->send())
     {
      echo 'Email sent.';
     }
     else
    {
     show_error($this->email->print_debugger());
    }

}
相关问题