當我嘗試發送來自localhost
的電子郵件時,一切正常。但是當我將我的應用程序上傳到服務器時,電子郵件功能不再有效!我使用Gmail帳戶。本地主機發送電子郵件但不在服務器中
這裏是我的config/email.php
文件:
$config['useragent'] = 'CodeIgniter';
$config['protocol'] = 'smtp';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'my_password';
$config['smtp_port'] = 465;
$config['smtp_timeout'] = 80;
$config['wordwrap'] = TRUE;
$config['wrapchars'] = 76;
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['validate'] = FALSE;
$config['priority'] = 3;
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";
$config['bcc_batch_mode'] = FALSE;
$config['bcc_batch_size'] = 200;
$config['sender_name'] = 'Name';
$config['from_email'] = '[email protected]';
$config['to_email'] = '[email protected]';
$config['email_subject'] = 'Email Subject';
這是我收到一封電子郵件在我的控制器:
$this->load->library('email');
$this->email->from($this->config->item('from_email'), $this->config->item('sender_name'));
$this->email->to($this->config->item('to_email'));
$this->email->subject($this->config->item('email_subject'));
$this->email->message($string);
if (!$this->email->send())
{
$data['success'] = FALSE;
}
else
{
$data['success'] = TRUE;
}
$this->_example_output('layouts/sendemail_confirm.php', $data);
這是我收到的錯誤:
遇到PHP錯誤
嚴重性:警告
消息:的fsockopen()[function.fsockopen]:無法連接到 SSL://smtp.googlemail.com:465(連接被拒絕)
文件名:庫/ Email.php
行號:1689
一個PHP錯誤遇到
嚴重性:警告
消息:fwrite的()預計參數1是資源,給定
文件名布爾:庫/ Email.php
行號:1846
遇到甲PHP錯誤
嚴重性:警告
消息:與fgets()預計參數1是資源,布爾給出
文件名:庫/ Email.php
行號:1869
後嘗試這樣做。沒有工作! – iTurki