mqzlp 发表于 2017-3-20 12:33:57

PHP mail函数

  书本上的代码:
  <?php
  //create short variable names
  $name=$_POST['name'];
  $email=$_POST['email'];
  $feedback=$_POST['feedback'];

  //set up some satatic information
  $toaddress="feedback@example.com";

  $subject="Feedback from web site";

  $mailcontent="Customer name:".$name."\n".
      "Customer email:".$email."\n".
      "Customer comments:\n".$feedback."\n";
  $fromaddress="From:webserver@example.com";

  //invoke mail() function on send mail ?
   mail($toaddress, $subject, $mailcontent, $fromaddress);
?>

<html>
<head>
 <title>Bob's Auto Parts --Feedback Submitted<title>
</head>
 <h1>Feedback submitted</h1>
 <p>Your feedback has been sent.</p>
</body>
</html>
Warning: mail() : Failed to connect to mailserver at "127.0.0.1" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\EasyPHP-5.3.5.0\www\test\processfeedback.php on line 18Call Stack  解决办法:
  安装hmail:

  查看数据库表:





  配置esayphp.ini [我用的是esayphp]
  
;For Win32 only.
smtp=localhost
smtp_port=25

;For Win32 only.
sendmail_from=youremail@163.com  
  ***********************
  不报错了,可以发邮件了
页: [1]
查看完整版本: PHP mail函数