使用mail函数

    技术2022-06-26  42

    简单地联系了一下mail函数的使用方法,具体记录如下(因为是为联系mail函数使用,所以未对参数做校验,假设所有输入均正确):

     

    1、sendmail.html

      

    <html><head>    <title>Send Mail</title></head><body><form action="sendmail.php" method="post"><table width="250" cellpadding="2" cellspacing="0" bgcolor="#cccccc"> <tr><td>subject:</td>     <td><input type="input" name="subject" size="60" maxlength="60"/></td></tr>    <tr><td>to:</td>     <td><input type="input" name="to" size="60" maxlength="60"/></td></tr> <tr><td>cc:</td>     <td><input type="input" name="cc" size="60" maxlength="60"/></td></tr> <tr><td>bcc:</td>     <td><input type="input" name="bcc" size="60" maxlength="60"/></td></tr> <tr><td>from:</td>     <td><input type="input" name="from" size="60" maxlength="60"/></td></tr> <tr><td>message:</td>     <td><textarea name="message" rows="10" cols="60"></textarea></td></tr> <tr><td colspan="2" align="center"><input type="submit" value="Send Mail"></td></tr></table></form></body></html>

     

     

    -------------------------------------

    2.sendmail.php

     

      <?php $subject = $_POST['subject']; $to = $_POST['to']; $cc = $_POST['cc']; $bcc = $_POST['bcc']; $from = $_POST['from']; $message = $_POST['message']; $headers="From:".$from."/r/n"."CC:".$cc."/r/n"."BCC:".$bcc; if(mail($to,$subject,$message,$headers)){ echo "OK"; }else{ echo "fail"; } ?>    


    最新回复(0)