2014-01-06 114 views
0

我读其他议题,但没有解决我的问题..笨 - 发送电子邮件Gmail的WAMP

我在我的控制器有这样的:

$this->load->library("email"); 
$this->email->from(set_value("email"), 
set_value("nome"),set_value("msg")); 
$this->email->to("[email protected]"); 
$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  = "[email protected]"; 
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  = "[email protected]"; 
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

但我有DA同样的问题...不行:

消息:电子邮件():无法连接到在MAILSERVER “本地主机” 25端口,验证 “SMTP” 和 “SMTP_PORT” 在php.ini中设置或使用的ini_set()

文件名:库/ Email.php

行号:1553 无法使用PHP邮件发送电子邮件()。您的服务器可能未配置为使用此方法发送邮件。

行号1553的email.php有这样的:

如果(电子邮件($本 - > _收件人,$此 - > _主题,$此 - > _ finalbody,$此 - > _ header_str! ,$ “-f” 这 - > clean_email($本 - > _头[ '从']))){ 返回FALSE;}其他{ 返回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

回答

1

试试这个自己测试过的代码。它可能会帮助你。 确保您在Gmail设置中启用了POP3。

$config['useragent'] = 'CodeIgniter'; 
$config['protocol']  = 'smtp'; 
$config['smtp_host'] = 'ssl://smtp.googlemail.com'; 
$config['smtp_user'] = '*****[email protected]'; // 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('[email protected]', 'TSS DEV'); 
$this->email->to('[email protected]'); 
$this->email->cc('[email protected]'); 

$this->email->subject('Email Test'); 
$this->email->message('Testing the email class.');  

$this->email->send(); 
+0

问题解决了,谢谢! – Sayoko

+0

很高兴知道它的工作。并欢迎:) –

0

试试这个:

$ci = get_instance(); 
$ci->load->library('email'); 
$config['protocol'] = "smtp"; 
$config['smtp_host'] = "ssl://smtp.gmail.com"; 
$config['smtp_port'] = "465"; 
$config['smtp_user'] = "[email protected]"; 
$config['smtp_pass'] = "yourpassword"; 
$config['charset'] = "utf-8"; 
$config['mailtype'] = "html"; 
$config['newline'] = "\r\n"; 

$ci->email->initialize($config); 

$ci->email->from('[email protected]', 'Blabla'); 
$list = array('[email protected]'); 
$ci->email->to($list); 
$this->email->reply_to('[email protected]', 'Explendid Videos'); 
$ci->email->subject('This is an email test'); 
$ci->email->message('It is working. Great!'); 
$ci->email->send(); 

WAMP服务器在线也...