2014-01-06 156 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服務器在線也...