请帮助我,使用Outlook(SMTP)发送电子邮件时,PHP返回“ 504 5.7.4无法识别的身份验证类型”。除了修改“ Exchange”服务器之外,还有其他方法吗,因为我没有“ Exchange”服务器的权限。 谢谢!
$this->host = 'smtp-mail.outlook.com';
$this->port = 25;
$this->auth = true;
$this->user = 'test001@outlook.com';
$this->pass = '123456';
function auth()
{
if (is_resource($this->connection)
AND $this->send_data('AUTH LOGIN')
AND substr($error = $this->get_data(), 0, 3) === '334'
AND $this->send_data(base64_encode($this->user)) // Send username
AND substr($error = $this->get_data(),0,3) === '334'
AND $this->send_data(base64_encode($this->pass)) // Send password
AND substr($error = $this->get_data(),0,3) === '235' )
{
return true;
}
else
{
$this->errors[] = 'AUTH command failed: ' . trim(substr($error, 3));
return false;
}
}
function send_data($data)
{
if (is_resource($this->connection))
{
return fwrite($this->connection, $data . CRLF, strlen($data) + 2);
}
else
{
return false;
}
}
function get_data()
{
$return = '';
$line = '';
if (is_resource($this->connection))
{
while (strpos($return, CRLF) === false OR $line{3} !== ' ')
{
$line = fgets($this->connection, 512);
$return .= $line;
}
return trim($return);
}
else
{
return '';
}
}