我已经更改了XAMPP的php.ini“sendmail_path ='/ usr / bin / msmtp -t'”但我仍然收到此错误:
An Error Was Encountered
220 smtp.googlemail.com ESMTP x66sm53059629pfb.86 - gsmtp
hello: 250-smtp.googlemail.com at your service, [203.177.142.78]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
Failed to authenticate password. Error: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 x66sm53059629pfb.86 - gsmtp
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Tue, 30 Aug 2016 07:21:37 +0200
From: "juan dela cruz" <sampleticketdaddress@gmail.com>
Return-Path: <sampleticketdaddress@gmail.com>
To: sampleticketdaddress@gmail.com
Subject: =?UTF-8?Q?Email=20Testing?=
Reply-To: <sampleticketdaddress@gmail.com>
X-Sender: sampleticketdaddress@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <57c517e10e70b@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Email is working great.
这是我正在使用的代码:
function index(){
$config = Array(
'protocol' =>'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'sampleticketdaddress@gmail.com',
'smtp_pass' => 'xxxxxx'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('sampleticketdaddress@gmail.com', 'some name');
$this->email->to('sampleticketdaddress@gmail.com');
$this->email->subject("Email Testing");
$this->email->message('Email is working great.');
if($this->email->send())
{
echo "Email has been sent.";
}
else
{
show_error($this->email->print_debugger());
}
}
}
我的密码是正确的,所以我认为问题不存在。你能告诉我我错在哪里或者我需要做些什么来使这个代码在Ubuntu中运行吗?谢谢。
答案 0 :(得分:0)
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'xxx@gmail.com',// your mail name
'smtp_pass' => '*****',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
'wordwrap' => TRUE
);
然后
$this->load->library('email', $config);
XAMPP中的邮件设置(无效)
$this->email->from('mygmail@gmail.com', 'myname');//your mail address and name
$this->email->to('target@gmail.com'); //receiver mail
$this->email->subject('testing');
$this->email->message($message);
$this->email->send(); //sending mail
sendmail.ini中的配置
路径c:\ xampp \ sendmail \ sendmail.ini
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
auth_username=myemail@gmail.com
auth_password=yourgmailpassword
force_sender=myemail@gmail.com
in php.ini
路径C:\ XAMPP \ XAMPP \ PHP \ php.ini中
[邮件功能]
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"