2013-06-28 185 views
2

嘿傢伙即時嘗試創建一個重置密碼爲這個論壇即時開發...無論如何,我跟着一堆指南,並嘗試了許多版本,你會看到什麼,這是最少的錯誤。 ..我仍然無法弄清楚什麼是錯,我可以使用你的幫助。Codeigniter發送SMTP郵件

class CI_Email { //in library email.php 

var $useragent  = "CodeIgniter"; 
var $mailpath  = "/usr/sbin/msmtp"; // Sendmail path 
var $protocol  = "smtp"; // mail/sendmail/smtp 
var $smtp_host  = "smtp.googlemail.com";  // SMTP Server. 
var $smtp_user  = "[email protected]";  // SMTP Username 
var $smtp_pass  = "mypass";  // SMTP Password 
var $smtp_port  = "465";  // SMTP Port 
var $smtp_timeout = 5;  // SMTP Timeout in seconds 
var $smtp_crypto = "";  // SMTP Encryption. Can be null, tls or ssl. 
var $mailtype  = "html"; // text/html Defines email formatting 
var $charset  = "utf-8"; // Default char set: iso-8859-1 or us-ascii 

這是結果:

hello: 
The following SMTP error was encountered: 
Failed to send AUTH LOGIN command. Error: 
from: 
The following SMTP error was encountered: 
to: 
The following SMTP error was encountered: 
data: 
The following SMTP error was encountered:

The following SMTP error was encountered: Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method. Content-Type: multipart/alternative; boundary="B_ALT_51cd96f2daf24"

This is a multi-part message in MIME format. Your email application may not support this format.

--B_ALT_51cd96f2daf24 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit

My text here...

--B_ALT_51cd96f2daf24 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

我也嘗試了很多其他配置的我在網上找到,如:

var $mailpath  = "/usr/sbin/sendmail"; // Sendmail path 
    var $smtp_host  = "ssl://smtp.googlemail.com";  // SMTP Server. 

或:

var $mailpath  = "/usr/sbin/sendmail"; // Sendmail path 
    var $smtp_host  = "ssl://smtp.gmail.com";  // SMTP Server. 

使用SSL協議在smtp_host我越來越無盡的錯誤無盡的屏幕。

+0

您正在使用什麼SMTP端口? –

+0

我使用我發現的指南建議的465端口...即時通訊相當新的東西是有另一個文件,我必須配置端口? – Dennis

+0

你可以接受這兩個: var $ smtp_host =「ssl://smtp.googlemail.com」; // SMTP服務器 var $ smtp_port =「25」; // SMTP端口 –

回答

2

我已經使用測試Gmail帳戶進行非生產CodeIgniter電子郵件測試,但是當我部署到生產服務器時,我使用ENVIRONMENT常量檢測正確的郵件連接設置。

對於Gmail,我發現這些配置設置(我已經把/application/config/email.php)很好地工作:

$config = Array(
     'protocol' => 'smtp', 
     'smtp_host' => 'ssl://smtp.googlemail.com', 
     'smtp_port' => 465, 
     'smtp_user' => '<test-account-name>@gmail.com', 
     'smtp_pass' => '<test-account-password>', 
    ); 

您的電子郵件很有可能被標記爲收件人垃圾郵件,直到他們白名單的發件人。

和FWIW,不要編輯核心CodeIgniter文件,你可以提供你的連接細節許多不同的方式。

+0

對不起,延遲...我明天會檢查這一天,我離開這些天...這只是我使用相同的配置,但可能我想念別的東西。 – Dennis

+0

感謝沃爾夫的幫助...實際上我使用這種格式來聲明我的配置文件,但我有一個服務器的問題,並不得不在php.ini文件中取消對extension = php_openssl.dll的註釋 – Dennis