我正在使用此脚本来计算主机服务器上使用的总存储量并发送包含详细信息的电子邮件。 到目前为止,它始终适用于不同的服务器,但新的服务器似乎需要身份验证才能发送电子邮件。
<?php
$filePath = "./";
$total = 0;
$d = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($filePath),
RecursiveIteratorIterator::SELF_FIRST
);
foreach($d as $file){
$total += $file->getSize();
}
$to = 'test@gmail.com';
$subject = "Storage " .number_format($total/1048576, 2);
$message = "Storage " .number_format($total/1048576, 2);
$headers = "MIME-Version: 1.0\n";
$headers .="Content-Type: text/html; charset=\"ISO-8859-1\"\n";
$headers .= 'From: XYZHost <test@domain.com>' . "\r\n" .
'Reply-To: test@domain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
ini_set("SMTP", "mail.domain.com");
mail($to, $subject, $message, $headers);
?>
传送失败并出现此错误:
Diagnostic-Code: smtp; 550-Verification failed for <account@xyz.hosting>
550-Called: ---
550-Sent: RCPT TO:<account@xyz.hosting>
550-Response: 550 5.1.1 User unknown: account@xyz.hosting
550 Invalid sender <account@xyz.hosting>
有没有办法在这里添加身份验证?