mail()函数一定要linux下面才能用的,而且要装上email服务器

解决方案 »

  1.   

    Example 1. Sending mail.mail("[email protected]", "My Subject", "Line 1\nLine 2\nLine 3");
     
    Example 2. Sending mail with extra headers.mail("[email protected]", "the subject", $message,
         "From: webmaster@$SERVER_NAME\r\n"
        ."Reply-To: webmaster@$SERVER_NAME\r\n"
        ."X-Mailer: PHP/" . phpversion());
     
    Example 3. Sending mail with extra headers and setting an additional command line parameter.mail("[email protected]", "the subject", $message,
         "From: webmaster@$SERVER_NAME", "-fwebmaster@$SERVER_NAME");
     
    Example 4. Sending complex email./* recipients */
    $to  = "Mary <[email protected]>" . ", " ; //note the comma
    $to .= "Kelly <[email protected]>";/* subject */
    $subject = "Birthday Reminders for August";/* message */
    $message = '
    <html>
    <head>
     <title>Birthday Reminders for August</title>
    </head>
    <body>
    <p>Here are the birthdays upcoming in August!</p>
    <table>
     <tr>
      <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
     </tr>
     <tr>
      <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
     </tr>
     <tr>
      <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
     </tr>
    </table>
    </body>
    </html>
    ';/* To send HTML mail, you can set the Content-type header. */
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";/* additional headers */
    $headers .= "From: Birthday Reminder <[email protected]>\r\n";$headers .= "Cc: [email protected]\r\n";
    $headers .= "Bcc: [email protected]\r\n";/* and now mail it */
    mail($to, $subject, $message, $headers);
     
    Example5:
    <?
    $message="abcdefghijklmnopqrstuvwxyz";
    mail("[email protected]", "没有主题", $message, "From: [email protected]\nReply-To: [email protected]\nX-Mailer: PHP/" . phpversion());
    ?> 
    不過一定要在linux下才能用。win2k是不能用的。
      

  2.   

    其实这个功能的话,只有有 smtp服务器即可,用mail 函数实现向指定的信箱发信。
    smtp服务器的的话,比较多,我用的 imail,可以去网上下载的,它的功能比较多的,注意的是要在 php.ini中的mail function中设置
    SMTP =localhost
    sendmail_from=你自己的信箱。
    还有mail()函数的参数不是很多吗?
    格式 boolean mail(string to, string subject, string message, string [additional_headers]);
    分别指 目标地址,主题,内容,以及 headers。
    列子就不举,如果还有什么问题,欢迎来信。
      

  3.   

    请问上面的师兄那么如果要是用smtp服务器的话,需要做什么设置吗?
    我的计算机里没有smtp应该到哪去找呀!请您再说得详细点可以吗?
    我将非常感谢。请您帮帮忙,我的确很着急!
      

  4.   

    在windows下面用PHP不可以发EMAIL吗?如果可以有没有简单点的方法呀!
    请各位多帮帮忙。我一定高分回报!
      

  5.   

    上www.NuSphere.com 下载他的自动安装包。装好以后 就可以用 mail() 函数发信了