ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

12-1-1 ¥Hmail()¨ç¼Æ±H«H

12-1-1 ¥Hmail()¨ç¼Æ±H«H

12-1-1   ¥Hmail()¨ç¼Æ±H«H
¨Ï¥Îmail()¨ç¼Æ¨Ó±H«H¬O³Ì®e©öªº¨Æ¤F¡I¦¹¨ç¼Æ®æ¦¡¦p¤U¡G
mail()¨ç¼Æ®æ¦¡
  1. bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]])
½Æ»s¥N½X

  • to°Ñ¼Æ¡G¦¬¥óªÌªºEmail¡A­Y­n¦P®Éµ¹¦h¤H¡A½Ð¥[¤J¡u¡A¡v³r¸¹¤À¹j¦¬¥ó¤H¡C
  • subject°Ñ¼Æ¡G«H¥óªº¥D¦®¼ÐÃD¡C
  • message°Ñ¼Æ¡G«H¥óªº¤º®e¡C
  • additional_headers°Ñ¼Æ¡G¹q¤l¶l¥óªþ¥[ªº¼ÐÀY¸ê°T¡A«D¥²­n°Ñ¼Æ¡C
  • additional_parameters°Ñ¼Æ¡G¨ä¥L¹q¤l¶l¥óªþ¥[¸ê°T¡A«D¥²­n°Ñ¼Æ¡C

¨Ò¦p¡G½d¨Òmailtest.php
  1. <?
  2. $To="[email protected]"; //½Ð§ï¦¨±z¦Û¤vªºEmail
  3. $Subject="mail()¨ç¼Æ´ú¸Õ";
  4. $Body="³o¬O«H¥ó¤º®e\n³o¬O«H¥ó¤º®e\n.....";
  5. $mailret=mail($To,$Subject,$Body);
  6. echo $mailret; //¦^¶Ç­È1¥Nªí«H¥ó±H°eok
  7. ?>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

¨Ï¥Îmail()¨ç¼Æ±H«H¡A°ò¥»¤W¥u»Ýµ¹©w¦¬¥ó¤H¡B¥D¦®¡B«H¥ó¤º®e§Y¥i¡A¤U¹Ï§Y¬°½d¨Òmailtest.php©Ò±H¥Xªº«H¥ó¡G

¹Ï12-1  mailtest.php©Ò±H¥Xªº«H¥ó¡C

¦b¤W¹Ï¤¤¡A§Ú­Ì¥i¥Hµo²{«H¥óªº±H¥óªÌ¬O¨t²Î¹w³]­È¡A¨º¤H®a¦p¦ó¦^«Hµ¹±z¡H³o®É­Ô¡A§Ú­Ì±N¥Î¨ìmail()¨ç¼Æªº²Ä¥|­Ó°Ñ¼Æ¡uadditional_headers¡v¡G½d¨Òmailtest2.php
  1. <?
  2. $To="[email protected]";
  3. $Subject="mail()¨ç¼Æ´ú¸Õ2";
  4. $Body="³o¬O«H¥ó¤º®e\n³o¬O«H¥ó¤º®e\n.....";
  5. $From="From: [email protected]";
  6. $mailret=mail($To,$Subject,$Body,$From);
  7. echo $mailret; //¦^¶Ç­È1¥Nªí«H¥ó±H°eok
  8. ?>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

¦pªG­n¥H¼ÊºÙ©Î©m¦W¥N´À¶l¥ó¦a§}¬°Åã¥Ü¤º®e¡A¥i¥H±N¶l¥ó¦a§}¥H¡u< >¡v¬A°_¨Ó¡A¨Ã©ó¡u< >¡v«e¤è©ñ¸m±z·QÅã¥Üªº¤å¦r¡A¦ý¦¹¤èªk¶È­­¡u±H¥óªÌ¦³®Ä¡v¡A¨Ò¦p¡G½d¨Òmailtest3.php
  1. <?
  2. $To="[email protected]";
  3. $Subject="mail()¨ç¼Æ´ú¸Õ3";
  4. $Body="³o¬O«H¥ó¤º®e\n³o¬O«H¥ó¤º®e\n.....";
  5. $From="From: ©~©ö<[email protected]>";
  6. $mailret=mail($To,$Subject,$Body,$From);
  7. echo $mailret; //¦^¶Ç­È1¥Nªí«H¥ó±H°eok
  8. ?>
½Æ»s¥N½X
­Y±z§Æ±æ¦¬¥óªÌ¤]¯à¥H¼ÊºÙ©Î©m¦W¥N´À¶l¥ó¦a§}¬°Åã¥Ü¤º®e¡A«h¥²¶·¦b¡uadditional_headers¡v°Ñ¼Æ¤¤¦A¥[¤J¤@¦¸¦¬¥óªÌ¸ê°T¡A¶l¥ó¦a§}¦P¼Ë¥H¡u< >¡v¬A°_¨Ó¡A¨Ã©ó¡u< >¡v«e¤è©ñ¸m±z·QÅã¥Üªº¤å¦r¡A¨Ò¦p¡G½d¨Òmailtest4.php
  1. <?
  2. $To="[email protected]";
  3. $Subject="mail()¨ç¼Æ´ú¸Õ4";
  4. $Body="³o¬O«H¥ó¤º®e\n³o¬O«H¥ó¤º®e\n.....";
  5. $From="From: ©~©ö <[email protected]>";
  6. $ToName="To: ¤p³½ <[email protected]>";
  7. $Head=$From . "\r\n" . $ToName;
  8. $mailret=mail($To,$Subject,$Body,$Head);
  9. echo $mailret; //¦^¶Ç­È1¥Nªí«H¥ó±H°eok
  10. ?>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

¥Ñ©ó§Ú­Ìªº¹q¤l¶l¥óªþ¥[ªº¼ÐÀY¸ê°T¦³¨â­Ó¡A©Ò¥H¨âªÌ¤§¶¡¥²¶·¥[¤J¡u\r\n¡v¤À¹j²Å¸¹¡A¤U¹Ï¬°½d¨Òmailtest4.php©Ò°e¥Xªº¶l¥ó¡A½Ðª`·N¬Ý¨ì±H¥óªÌ»P¦¬¥óªÌ¬Ò¥H¼ÊºÙ©Î©m¦W¥N´À¶l¥ó¦a§}¬°Åã¥Ü¤º®e¡G

¹Ï12-2  mailtest4.php©Ò±H¥Xªº«H¥ó¡C

«Ü²M·¡¤F³á¡I²{¦b§Ú­Ì´N¨Ó»s§@¤@­Óªí³æ±H«Hµ{¦¡¡A·í§Ú­Ì¦b¶ñ¼g«H¥ó¤º®e®Éµe­±¦p¤U¹Ï¡G

¹Ï12-3   mailform.php¡G¶ñ¼g«H¥ó¤º®e¡C

·í§Ú­Ì«ö¤Uªí³æ¤¤ªº¡u°e¥X¡v«ö¶s«á¡Aªí³æ¸ê®Æ°eµ¹mailform.phpµ{¦¡¦Û¤v³B²z¡A±N«H¥ó°e¥X«áµe­±¦p¤U¹Ï¡G
3.png
¹Ï12-4  mailform.php¡G«H¥ó°e¥X«á¡C
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

mailform.php
  1. <?
  2. if (isset($_REQUEST["ord"]))
  3. {
  4. //¨ú±o¶ñ¼gªº¸ê®Æ
  5. $To="[email protected]"; //§ï¦¨±z¦Û¤vªºMAIL
  6. $From="From" . $_REQUEST["mailfrom"];
  7. $Subject=$_REQUEST["mailsubject"];
  8. $Body=$_REQUEST["mailtext"];
  9. //°e¥X«H¥ó
  10. $mailret=mail($To,$Subject,$Body,$From);
  11. if ($mailret==1)
  12.    {
  13.     $msg="·PÁ±zªº·N¨£";
  14.    }
  15.    else
  16.    {
  17.     $msg="«H¥ó±H°e¿ù»~";
  18.    }
  19. ?>
  20. <html>
  21. <head>
  22. <meta http-equiv="Content-Type" content="text/html; charset=big5">
  23. <title>·PÁ±zªº·N¨£!!</title>
  24. </head>
  25. <body>
  26. <?=$msg;?>
  27. </body>
  28. </html>
  29. <?
  30. }
  31. else
  32. {
  33. ?>
  34. <html>
  35. <head>
  36. <meta http-equiv="Content-Type" content="text/html; charset=big5">
  37. <title>·N¨£¦^õX</title>
  38. </head>
  39. <div align=center><center>
  40. <table border=1 bordercolordark=#FFFFFF cellspacing=0 cellpadding=0 bordercolorlight=#800000 bordercolor=#800000>
  41. <tr><td width=100% bgcolor=#800000>
  42. <form method=POST action="<?=$_SERVER["PHP_SELF"];?>" style="margin-top: 0; margin-bottom: 0">
  43. <table border=1 bordercolorlight=#800000 cellspacing=0 cellpadding=0 bordercolordark=#FFFFFF bordercolor=#FFFFFF>
  44. <tr><td width=22% bgcolor=#000080>
  45. <font color=#FFFFFF size=2>±H¥óªÌEMAIL</font></td>
  46. <td width=78% ><input type=text name=mailfrom size=46></td></tr>
  47. <tr><td width=22% bgcolor=#000080>
  48. <font color=#FFFFFF size=2>«H¥ó¥D¦®</font></td>
  49. <td width=78% ><input type=text name=mailsubject size=46></td></tr>
  50. <tr><td width=22% bgcolor=#000080>
  51. <font color=#FFFFFF size=2>«H¥ó¤º®e</font></td>
  52. <td width=78% ><textarea rows=6 name=mailtext cols=45></textarea></td></tr>
  53. <tr><td width=100% colspan=2><p align=center>
  54. <input type=submit value=°e¥X name=ord></td></tr>
  55. </table></form>
  56. </td>
  57. </tr></table></center></div>
  58. </body>
  59. </html>
  60. <?
  61. }
  62. ?>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

¦^´_ 5# ¤p»x


    ½Ð°Ý¤@¤U§Ú¤º¤åªº³¡¤À¦]¬°­n¿é¤J¸ê®Æ
¥i¬O¦b¹ï¤è¿é¤J¤¤¦³«öenter
©Ò¥H¤º¤å·|¦³<br /> ¨ú¥Nenterªº³¡¥÷
À³¸Ó¬O¦]¬°±H°e¤è¦¡¬°txt
­n«ç»ò§ï¦¨html®æ¦¡
¥N½X¦p¤U
  1. <?php

  2.          
  3.          
  4. $to = "****@******";
  5. $subject = nl2br($_POST['subject']);


  6. $txt1 ="Ápµ¸¤H:" .nl2br($_POST['sendname']). "\r\n" ."Ápµ¸¹q¸Ü:".nl2br($_POST['sendphone']). "\r\n" ."±Ï§U¤º®e:".nl2br($_POST['sendbody']);
  7. $headers = "From: ***@*******" . "\r\n" .
  8. "CC: ***@******";

  9. mb_internal_encoding("utf-8");//³]©w½s½X¤è¦¡  
  10. mb_send_mail($to,$subject,$txt1,$headers);//±H¥X«H¥ó



  11. ?>
  12. <html>
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; chaRSet=utf-8">
  15. <title>·PÁ±zªº¯d¨¥!!</title>
  16. <meta http-equiv="refresh" content="3; url=../help.htm">
  17. </head>
  18. <body>
  19. <p>·PÁ±zªº¯d¨¥§Ú­Ì±N¥H³Ì§Ö³t«×»P±zÁpô</p>
  20. <p> ¤T¬íÄÁ¤§«á¦Û°Ê¦^«e¤@­¶ </p>
  21. <p>©Î<a href="../html/help.htm" style="font-family: '²Ó©úÅé'; font-size: 30px; color: #C00;">«ö¦¹</a>ª½±µ¦^«e¤@­¶</p>
  22. </body>
  23. </html>
½Æ»s¥N½X
¥ý¦b¦¹·PÁ¤j¤j
¯¬·s¦~§Ö¼Ö

TOP

¦^´_ 6# toxin
  1. <?
  2. if (isset($_REQUEST["ord"]))
  3. {
  4. //¨ú±o¶ñ¼gªº¸ê®Æ
  5. $To="[email protected]"; //§ï¦¨±z¦Û¤vªºMAIL
  6. $From= $_REQUEST["mailfrom"];
  7. $Subject=$_REQUEST["mailsubject"];
  8. $Body=$_REQUEST["mailtext"];
  9. $sHeaders = "MIME-Version: 1.0\r\n" .  "Content-type: text/html; charset=big5\r\n" . "From: $From\r\n";
  10. //°e¥X«H¥ó
  11. $mailret=mail($To,$Subject,$Body,$sHeaders);
  12. if ($mailret==1)
  13.    {
  14.     $msg="·PÁ±zªº·N¨£";
  15.    }
  16.    else
  17.    {
  18.     $msg="«H¥ó±H°e¿ù»~";
  19.    }
  20. ?>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

½Ð°Ý¤p»x
mail()¦³¿ìªk§Q¥Î±ø¥ó¦¡±H«H¶Ü?
·í±ø¥ó¦¨¥ß¥u±H¤@¦¸«H?
ÁÂÁÂ!!

TOP

        ÀR«ä¦Û¦b : ¡i¬°µ½Ävª§¡j¤H¥Í­n¬°µ½Ävª§¡A¤À¬í¥²ª§¡C
ªð¦^¦Cªí ¤W¤@¥DÃD