我读了其他主题但未解决我的问题..
我在控制器中有这个:
$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();
和我的图书馆电子邮件:
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;
...
我也改变了php.ini :( wamp - bin - apache - apache2.4.4 - bin - php.ini)
延长= php_openssl.dll
但我有同样的问题...不工作:
消息:mail():无法连接到“localhost”端口25的邮件服务器,验证php.ini中的“SMTP”和“smtp_port”设置或使用ini_set()
文件名:libraries / Email.php
行号:1553 无法使用PHP mail()发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。
email.php的第1553行包含:
if(!mail($ this-> _recipients,$ this-> _subject,$ this-> _finalbody,$ this-> _header_str,“ - f”。$ this-> clean_email($ this - > _headers [ '从']))){ return FALSE;} else { 返回TRUE;}
if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this-_header_str, "-f ".$this->clean_email($this->_headers['From']))){
return FALSE;
}else{
return TRUE;
}
我需要帮助...... tks
答案 0 :(得分:2)
试试这个自我测试代码。它可能会帮助你。 确保在gmail设置中启用了POP3。
$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'] = "\r\n";
$config['crlf'] = "\r\n";
$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 :(得分:1)
试试这个:
$ci = get_instance();
$ci->load->library('email');
$config['protocol'] = "smtp";
$config['smtp_host'] = "ssl://smtp.gmail.com";
$config['smtp_port'] = "465";
$config['smtp_user'] = "blablabla@gmail.com";
$config['smtp_pass'] = "yourpassword";
$config['charset'] = "utf-8";
$config['mailtype'] = "html";
$config['newline'] = "\r\n";
$ci->email->initialize($config);
$ci->email->from('blablabla@gmail.com', 'Blabla');
$list = array('xxx@gmail.com');
$ci->email->to($list);
$this->email->reply_to('my-email@gmail.com', 'Explendid Videos');
$ci->email->subject('This is an email test');
$ci->email->message('It is working. Great!');
$ci->email->send();
将 WAMP 服务器置于在线也......