dongzhang5787 2014-01-06 23:48
浏览 48
已采纳

codeigniter - 发送电子邮件wamp gmail

I read other topics but not resolved my problem..

I have this in my controller:

$this->load->library("email");  
$this->email->from(set_value("email"),
set_value("nome"),set_value("msg"));  
$this->email->to("my@gmail.com");
$this->email->subject("Mensagem");
$this->email->message(set_value("msg"));
$this->email->send();
echo  $this->email->print_debugger();

and my library email:

var $useragent = "CodeIgniter";
var $mailpath       = "/usr/sbin/sendmail";
var $protocol       = "smtp";
var $smtp_host      = "smtp.gmail.com";
var $smtp_user      = "xxx@gmail.com";
var $smtp_pass      = "xxx";
var $smtp_port      = "465";
var $smtp_timeout   = 5;
var $smtp_crypto    = "";
var $wordwrap       = TRUE;
var $wrapchars      = "76";
var $mailtype       = "html";
var $charset        = "utf-8";
var $multipart      = "mixed";
var $alt_message    = '';   
var $validate       = FALSE;
var $useragent = "CodeIgniter";
var $mailpath       = "/usr/sbin/sendmail";
var $protocol       = "smtp";
var $smtp_host      = "smtp.gmail.com";
var $smtp_user      = "xxx@gmail.com";
var $smtp_pass      = "xxx";
var $smtp_port      = "465";
var $smtp_timeout   = 5;
var $smtp_crypto    = "";
var $wordwrap       = TRUE;
var $wrapchars      = "76";
var $mailtype       = "html";
var $charset        = "utf-8";
var $multipart      = "mixed";
var $alt_message    = '';   
var $validate       = FALSE;

...

I also change php.ini for: (wamp - bin - apache - apache2.4.4 - bin - php.ini)

extension=php_openssl.dll

But I have da same problem... not work:

Message: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

Filename: libraries/Email.php

Line Number: 1553 Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.

Line Number 1553 for email.php have this:

if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f ".$this->clean_email($this->_headers['From']))){ return FALSE;}else{ return TRUE;}

if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this-_header_str, "-f ".$this->clean_email($this->_headers['From']))){
    return FALSE;
}else{
    return TRUE;
}

I need help... tks

  • 写回答

2条回答 默认 最新

  • dtp87205 2014-01-07 06:30
    关注

    Try this self TESTED Code. It may help you. Make sure you have POP3 enabled in gmail Settings.

    $config['useragent']    = 'CodeIgniter';
    $config['protocol']     = 'smtp';
    $config['smtp_host']    = 'ssl://smtp.googlemail.com';
    $config['smtp_user']    = '*****developer@gmail.com'; // Your gmail id
    $config['smtp_pass']    = '**********'; // Your gmail Password
    $config['smtp_port']    = 465;
    $config['wordwrap']     = TRUE;    
    $config['wrapchars']    = 76;
    $config['mailtype']     = 'html';
    $config['charset']      = 'iso-8859-1';
    $config['validate']     = FALSE;
    $config['priority']     = 3;
    $config['newline']      = "
    ";
    $config['crlf']         = "
    ";
    
    $this->load->library('email');
    $this->email->initialize($config);
    
    $this->email->from('trimantradeveloper@gmail.com', 'TSS DEV');
    $this->email->to('trimantra@trimantra.com'); 
    $this->email->cc('trimantra@gmail.com'); 
    
    $this->email->subject('Email Test');
    $this->email->message('Testing the email class.');    
    
    $this->email->send();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 这个复选框什么作用?
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下