我正在尝试使用 php 中的邮件功能发送电子邮件:
$subject = 'testing';
$email = 'test@gmail.com';
$message = 'test message';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: The test site" . "\r\n";
if (mail($email, $subject, $message, $headers)) {
$data['msg']="Message send successfully";
}
else {
$data['msg']="Please try again, Message could not be sent!";
}
我遇到以下错误:
A PHP Error was encountered
Severity: Warning
Message: mail() [function.mail]: SMTP server response: 501 Syntax error in parameters or arguments
Filename: sendemail.php
Line Number: 40
我可能猜测该错误是由于未设置在 php 中发送电子邮件所需的配置。我应该做什么,或者我必须更改 php.ini 文件,但它无法访问。请问有什么解决办法吗?