碰到个mail()函数的问题,试了好几天仍旧无法解决。大家看看
 
(1)写了程序
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//en" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
 <head>
   <title> hello,php!! </title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <meta name="Author" content="">
   <meta name="Keywords" content="">
   <meta name="Description" content="">
 </head>
 <body>
   <h1 bgcolor="red">这是李正辉的第一个php程序</h1></br>
   <?php
   $firstname = $_POST['firstname'];
   $last_name = $_POST['lastname'];
   $when_it_happened = $_POST['whenithappened'];
   $how_long = $_POST['howlong'];
   $how_many = $_POST['howmany'];
   $alien_description = $_POST['aliendescription'];
   $what_they_did = $_POST['whattheydid'];
   $fang_spotted = $_POST['fangspotted'];
   $email = $_POST['email'];
   $other = $_POST['other'];   echo '她的名字是---' . $firstname . '</br>';
   $lastname = $_POST['lastname'];
   echo '他的名字是---' . $lastname; 
   $to = '[email protected]';
   $subject = 'Aliens Abducted Me - Abduction Report';
   $msg = $name .'was abducted'. $when_it_happened .'and was gone for'. $how_long .
      'Number of aliens:'. $how_many .
     'Alien description:'. $alien_description .
     'What they did:'. $what_they_did .
     'Fang spotted:'. $fang_spotted .
     'Other comments:'. $other;
   mail($to, $subject, $msg, 'From:' . $email); 
?>
 </body>
 </html>
 $email变量从这个表单填写后传入:
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <title>Aliens Abducted Me - Report an Abduction</title>
   <link rel="stylesheet" type="text/css" href="style.css" />
 </head>
 <body>
   <h2>Aliens Abducted Me - Report an Abduction</h2>
   <p>Share your story of alien abduction:</p>
   <form method="post" action="report.php">
     <label for="firstname">First name:</label>
     <input type="text" id="firstname" name="firstname" /><br />
     <label for="lastname">Last name:</label>
     <input type="text" id="lastname" name="lastname" /><br />
     <label for="email">What is your email address?</label>
     <input type="text" id="email" name="email" /><br />
     <label for="whenithappened">When did it happen?</label>
     <input type="text" id="whenithappened" name="whenithappened" /><br />
     <label for="howlong">How long were you gone?</label>
     <input type="text" id="howlong" name="howlong" /><br />
     <label for="howmany">How many did you see?</label>
     <input type="text" id="howmany" name="howmany" /><br />
     <label for="aliendescription">Describe them:</label>
     <input type="text" id="aliendescription" name="aliendescription" /><br />
     <label for="whattheydid">What did they do to you?</label>
     <input type="text" id="whattheydid" name="whattheydid" size="32" /><br />
     <label for="fangspotted">Have you seen my dog Fang?</label>
     Yes <input id="fangspotted" name="fangspotted" type="radio" value="yes" />
     No <input id="fangspotted" name="fangspotted" type="radio" value="no" /><br />
     <img src="fang.jpg" width="100" height="175"
       alt="My abducted dog Fang." /><br />
     <label for="other">Anything else you want to add?</label>
     <textarea id="other" name="other"></textarea><br />
     <input type="submit" value="Report Abduction" name="submit" />
   </form>
 </body>
 </html>
 (二)  配置php.ini文件
 
[mail function]
 ; For Win32 only.
 SMTP = smtp.qq.com
 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 =
 ; Force the addition of the specified parameters to be passed as extra parameters
 ; to the sendmail binary. These parameters will always replace the value of
 ; the 5th parameter to mail(), even in safe mode.
 ;mail.force_extra_parameters =
 试了无数次,换了n个smtp邮件服务器都无法发送成功。
 原因在哪?诚心指教

解决方案 »

  1.   

    目标 SMTP 必须是不需要验证的
      

  2.   

    我好像上传过一个 mail 插件, 里面有方法 自己去下载用吧
      

  3.   

    能是能但是自己的电脑要安装有插件  你百度下 class.phpmailer.php  找到这个插件  看相应的文档就就明白了  用mail()问题太了  要是不明白Q我  给你代码  代码实在太长了  不便在这里贴出来。。
      

  4.   

    这个需压配置本地smtp~建议还是用mail类