2016-03-12 103 views
3

編輯: 我試圖使用codeigniter的庫發送電子郵件。每當我叫$這個 - >的電子郵件 - >發送()函數返回在Codeigniter電子郵件庫中調用發送方法時出錯

Warning: include(C:\xampp\htdocs\psems\application\views\errors\html\error_php.php): failed to open stream: No such file or directory in C:\xampp\htdocs\psems\system\core\Exceptions.php on line 269

Warning: include(): Failed opening 'C:\xampp\htdocs\psems\application\views\errors\html\error_php.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\psems\system\core\Exceptions.php on line 269

這是我到目前爲止的代碼

$config = array(); 
    $config['useragent']   = "CodeIgniter"; 
    $config['mailpath']   = "/usr/bin/sendmail"; // or "/usr/sbin/sendmail" 
    $config['protocol']   = "smtp"; 
    $config['smtp_host']   = "localhost"; 
    $config['smtp_port']   = "25"; 
    $config['mailtype'] = 'html'; 
    $config['charset'] = 'utf-8'; 
    $config['newline'] = "\r\n"; 
    $config['wordwrap'] = TRUE; 

    $this->load->library('email'); 

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

    $this->email->from('[email protected]', 'harold decapia'); 
    $this->email->to('[email protected]'); 

    $this->email->subject('Тест Email'); 
    $this->email->message('Hello World'); 

    $this->email->send(); //I tried commenting this out and there was no error returned 

我很困惑,爲什麼它返回一個錯誤只需調用send方法。我必須先配置一些東西嗎?我想我在這裏失蹤的信息:(

而且一點點,有什麼辦法讓我知道了什麼錯誤它專門返回?據預先感謝您

+0

嘗試回聲$這個 - >的電子郵件 - > print_debugger(); –

+0

嘗試過,並且它說:「遇到以下SMTP錯誤:10061由於目標計算機主動拒絕,無法建立連接。 無法使用PHP SMTP發送電子郵件。您的服務器可能未配置爲使用此方法發送郵件。 「 –

+0

你有沒有嘗試PHP郵件程序庫的smtp –

回答

0

的錯誤,因爲我可以看到它的到來,因爲你試圖在沒有和實際的FTP服務器的服務器上發送帶有SMTP的電子郵件(與本地服務器發生很多事情)。

我將建議一個免費服務,如Mailgun用作一個SMTP服務器,而你正在開發。

此外,如果你要使用SMTP協議,你需要使用用戶和Passw ord在SMTP服務器上進行身份驗證(Mailgun也會爲您提供)。

這是SMTP服務器/身份驗證新配置的示例,請記住您需要根據Mailgun網站在您的帳戶中提供的信息進行調整。

$config['protocol'] = 'smtp'; 
$config['smtp_host'] = 'ssl://smtp.mailgun.org'; 
$config['smtp_port'] = '465'; 
$config['smtp_timeout'] = '30'; 
$config['smtp_user'] = '[email protected]'; 
$config['smtp_pass'] = 'password'; 
$config['charset'] = 'utf-8'; 
$config['mailtype'] = 'html'; 
$config['wordwrap'] = TRUE; 
$config['newline'] = "\r\n"; 

:)

+0

謝謝你的回答。我仍然不能發送,雖然我已經從Mailgun的用戶和密碼憑據。但是當我運行我的代碼它說:「無法驗證密碼。錯誤:535 5.7.0業務驗證 無法使用PHP SMTP發送電子郵件您的服務器可能未配置爲使用此方法發送郵件「我認爲這與我的密碼輸入錯誤有關,只是複製並粘貼它。我不知道爲什麼它會返回一個失敗的密碼驗證:( –

+0

@HaroldDecapia再次檢查mailgun儀表板以查看密碼是否因某些奇怪的原因而沒有更改。 –