【发布时间】:2010-12-22 07:36:00
【问题描述】:
<?php
//define the receiver of the email
$to = 'pradz39@gmail.com';
//define the subject of the email
$subject = 'Test email';
//define the message to be sent. Each line should be separated with \n
$message = "Hello";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
//send the email
$mail_sent = mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
我正在使用 xampp for windows 你能帮我配置 smtp 服务器吗.....
输出是
警告:mail() [function.mail]:无法在“localhost”端口 25 连接到邮件服务器,请验证 php.ini 中的“SMTP”和“smtp_port”设置或在 D:\installed 中使用 ini_set() \xampp\htdocs\mail.php 在第 13 行 邮件失败
【问题讨论】:
-
需要更多数据。去掉
mail前面的错误抑制操作符@,看看它是否吐出错误/警告。 -
我同意,删除@,记下错误并将其发布到 SO。