2017-11-27 3 views
0

CodeIgniterの設定:PHPMailer SMTP connect()に失敗しました。解決する方法?

$config['useragent']  = 'PHPMailer';    // Mail engine switcher: 'CodeIgniter' or 'PHPMailer' 
$config['protocol']   = 'smtp';     // 'mail', 'sendmail', or 'smtp' 
$config['mailpath']   = '/usr/sbin/sendmail'; 
$config['smtp_host']  = 'smtp.gmail.com'; 
$config['smtp_user']  = '[email protected]'; 
$config['smtp_pass']  = '####'; 
$config['smtp_port']  = 465; 

CodeIgniterのコントローラ:

$this->load->library('email'); 
$this->email->from('[email protected]', 'Webers Infotech'); 
$this->email->to('[email protected]','Rushabh Shah'); 
$this->email->subject('Your Subject'); 
$this->email->message('Your Message'); 
if (!$this->email->send()) { 
    show_error($this->email->print_debugger()); 
} 

誰がどのように私はこの問題を解決することができますを教えていただけますか?それはなぜ機能しないのですか?

+1

エラーは何ですか? –

+0

サーバのDNSルックアップが壊れていると、SMTP接続に失敗することがあります。あなたはチェックしました – Deep

+0

@DeepKakkarいいえ私はそれをチェックしていません。どうすれば確認できますか? –

答えて

0

次のコードで確認することができます。

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

$config['protocol'] = 'smtp'; 
$config['smtp_host'] = 'smtp.app.com'; // if via gmail 'ssl://smtp.googlemail.com'; 
$config['smtp_user'] = '[email protected]'; 
$config['smtp_pass'] = 'smtp password'; 
$config['smtp_port'] = port number; 
$config['starttls'] = TRUE; 

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

$this->email->from('[email protected]'); 
$this->email->to('[email protected]'); 
$this->email->subject('testing'); 
$this->email->message('Message content'); 

if($this->email->send()) { 
    echo 'Message has been sent'; 
} else { 
    $this->email->print_debugger(); 
} 

php_smtp.dllを確認してください。それは利用可能か否か。

は、あなたが見つからない場合は php.iniファイルを確認

<?php 
phpinfo(); 
?> 

を使用することができますし、

;extension=php_extname.dll 

だけの削除とラインが存在すべきであることを確認するには、この行からphpサービスを再起動します(Apacheを再起動します)。

+0

afaik 'php_smtp.dll'のようなものはありません – sintakonte

関連する問題