我已经写了一小块的PHP代码发送邮件:无法连接到邮件服务器在PHP
<?php
//define the receiver of the email
$to = '[email protected]';
//define the subject of the email
$subject = 'Hishob email';
//define the message to be sent. Each line should be separated with \n
$message = "Hello World!\n\nThis is my first mail.";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: [email protected]\r\nReply-To: [email protected]";
//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";
?>
执行它后,我得到了以下警告:
无法连接到邮件服务器在“localhost”端口25上,在php.ini中验证您的“SMTP”和“smtp_port”设置或在第11行的C:\ wamp \ www \ NewHishob \ PhpFiles \ send_mail.php中使用ini_set()
邮件失败
我正在使用WAMP服务器,并且有两个文件,INI-DIST和其他INI-RECOMENDED。哪一个很重要?
我也通过的php.ini-dist的文件不见了,用于SMTP它包含以下内容:
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
;sendmail_from = [email protected]
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
请建议我应该怎么办呢?感谢所有提前。
WAMP不是服务器。 WAMP是Windows,Apache2 webserver,MySQL dbms和PHP脚本引擎组合的“代号”。 – 2011-01-22 15:19:14