我的服务器是Red Hat Enterprise Linux Server 7.1版。 我正在尝试使用localhost发送简单的电子邮件。
$to = 'kosala@xxxxxx.com;
$subject = 'Fake sendmail test';
$message = 'If we can read this, it means that our fake Sendmail setup works!';
$headers = 'From: myemail@egmail.com' . "\r\n" .
'Reply-To: myemail@gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (mail($to, $subject, $message, $headers)) {
echo 'Email sent successfully!';
} else {
die('Failure: Email was not sent!');
}
回复是:电子邮件已成功发送!
但是我没有收到任何邮件。我的smtp端口25打开了,我用下面的命令检查了它。
nmap -sT -O localhost
echo "test" | sendmail xxxx@gmail.com
命令的输出是
您在/ var / spool / mail / root
中有新邮件
提前致谢,Kosala