我正在開發一個php codeigniter項目,我想從本地主機發送郵件。如何使用php發送本地主機的郵件CodeIgniter
以下是我的控制器功能。
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.google.com',
'smtp_port' => 465,
'smtp_user' => '[email protected]',
'smtp_pass' => 'password'
);
$this->load->library('email',$config);
$this->email->set_newline("\r\n");
$this->email->from("[email protected]");
$this->email->to("[email protected]");
$this->email->subject("Email with Codeigniter");
$this->email->message("This is email has been sent with Codeigniter");
if($this->email->send())
{
echo "Your email was sent.!";
} else {
show_error($this->email->print_debugger());
}
請注意,我已啓用php.ini中的'extension = php_openssl.dll'擴展名。我的php.ini文件位於C:/ AppServ/php5。當我運行代碼時,我的頁面加載錯誤。
這些都是錯誤的:
The following SMTP error was encountered: 1923818231 Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? Unable to send data: AUTH LOGIN Failed to send AUTH LOGIN command. Error: Unable to send data: MAIL FROM:
Severity: Warning
Message: date(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.
Filename: libraries/Email.php
Line Number: 705
難道您激活' PHP中的php_openssl'擴展?通過編輯'php.ini'並刪除'#'註釋來激活它 – RiggsFolly
我已經在php.ini中啓用了'extension = php_openssl.dll'擴展。我的php.ini文件位於C:/ AppServ/php5和C:/ AppServ/php7文件夾中 –
那裏的'wherever \ apache \ bin'中的一個可能被web服務器使用的文件 – RiggsFolly