このウェブサイトや他の多くのウェブサイトで同じ質問を見たことがありますが、彼らが提供した解決策は私にとってはうまくいきません. だから私は再び尋ねています。
メールを送信するには、次のコードを書きました
<?php
class Email extends CI_Controller{
function __construct()
{
parent::__construct();
}
function index()
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'username' => 'mymail@gmail.com',
'password' => 'password'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('mymail@gmail.com', 'mymail bcc');
$this->email->to('mymail@gmail.com');
$this->email->subject('This is a test email');
$this->email->message('Oops This is Great.');
if($this->email->send())
{
echo 'Your email was sent';
}
else
{
show_error($this->email->print_debugger());
}
}
}
openssl をインストールし、php.ini から extension=php_openssl.dll 行のコメントを外しました。しかし、次のエラーが発生します
An Error Was Encountered
220 mx.google.com ESMTP qp6sm2730344pbc.55
hello: 250-mx.google.com at your service, [119.30.39.78]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH
250 ENHANCEDSTATUSCODES
from: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 qp6sm2730344pbc.55
The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn
more at
530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 qp6sm2730344pbc.55
to: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 qp6sm2730344pbc.55
The following SMTP error was encountered: 530-5.5.1 Authentication Required.
Learn more at
530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 qp6sm2730344pbc.55
data: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1
http://support.google.com/mail/bin/answer.py?answer=14257 qp6sm2730344pbc.55
The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 qp6sm2730344pbc.55
502 5.5.1 Unrecognized command. qp6sm2730344pbc.55
The following SMTP error was encountered: 502 5.5.1 Unrecognized command. qp6sm2730344pbc.55
Unable to send email using PHP SMTP. Your server might not be configured to send
mail using this method.
parent::CI_Controller(); を使用する場合 Fatal error: Call to undefined method CI_Controller::CI_Controller() in C:\wamp\www\test\application\controllers\email.php on line 6 私はphp 5.4.3を使用していますが
ここで何が欠けているか教えてください。