<html> <head> <title>ThaiCreate.Com PHP Sending Email</title> </head> <body> <?php $strTo = "[email protected]"; $strSubject = "Test Send Mail"; $strMessage = "My Body & <b>My Description</b>"; //*** Uniqid Session ***// $strSid = md5(uniqid(time())); $strHeader = ""; $strHeader .= "From: Mr.Weerachai Nukitram<[email protected]>\nReply-To: [email protected]\n"; $strHeader .= "Cc: Mr.Surachai Sirisart<[email protected]>"; $strHeader .= "Bcc: [email protected]"; $strHeader .= "MIME-Version: 1.0\n"; $strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n"; $strHeader .= "This is a multi-part message in MIME format.\n"; $strHeader .= "--".$strSid."\n"; $strHeader .= "Content-type: text/html; charset=windows-874\n"; // or UTF-8 // $strHeader .= "Content-Transfer-Encoding: 7bit\n\n"; $strHeader .= $strMessage."\n\n"; //*** Files 1 ***// $strFilesName1 = "thaicreate1.txt"; $strContent1 = chunk_split(base64_encode(file_get_contents($strFilesName1))); $strHeader .= "--".$strSid."\n"; $strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName1."\"\n"; $strHeader .= "Content-Transfer-Encoding: base64\n"; $strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName1."\"\n\n"; $strHeader .= $strContent1."\n\n"; //*** Files 2 ***// $strFilesName2 = "thaicreate2.txt"; $strContent2 = chunk_split(base64_encode(file_get_contents($strFilesName2))); $strHeader .= "--".$strSid."\n"; $strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName2."\"\n"; $strHeader .= "Content-Transfer-Encoding: base64\n"; $strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName2."\"\n\n"; $strHeader .= $strContent2."\n\n"; $flgSend = @mail($strTo,$strSubject,null,$strHeader); // @ = No Show Error // if($flgSend) { echo "Email Sending."; } else { echo "Email Can Not Send."; } ?> </body> </html>
<html> <head> <title>ThaiCreate.Com PHP Sending Email</title> </head> <body> <?php $strTo = "[email protected]"; $strSubject = "Test Send Mail"; $strMessage = "My Body & <b>My Description</b>"; //*** Uniqid Session ***// $strSid = md5(uniqid(time())); $strHeader = ""; $strHeader .= "From: Mr.Weerachai Nukitram<[email protected]>\nReply-To: [email protected]\n"; $strHeader .= "Cc: Mr.Surachai Sirisart<[email protected]>"; $strHeader .= "Bcc: [email protected]"; $strHeader .= "MIME-Version: 1.0\n"; $strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n"; $strHeader .= "This is a multi-part message in MIME format.\n"; $strHeader .= "--".$strSid."\n"; $strHeader .= "Content-type: text/html; charset=windows-874\n"; // or UTF-8 // $strHeader .= "Content-Transfer-Encoding: 7bit\n\n"; $strHeader .= $strMessage."\n\n"; //*** Attachment Files ***// $arrFiles[] = "thaicreate1.txt"; $arrFiles[] = "thaicreate2.txt"; $arrFiles[] = "thaicreate3.txt"; $arrFiles[] = "thaicreate4.txt"; $arrFiles[] = "thaicreate5.txt"; for($i=0;$i<count($arrFiles);$i++) { if(trim($arrFiles[$i]) != "") { $strFilesName = $arrFiles[$i]; $strContent = chunk_split(base64_encode(file_get_contents($strFilesName))); $strHeader .= "--".$strSid."\n"; $strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n"; $strHeader .= "Content-Transfer-Encoding: base64\n"; $strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n"; $strHeader .= $strContent."\n\n"; } } $flgSend = @mail($strTo,$strSubject,null,$strHeader); // @ = No Show Error // if($flgSend) { echo "Email Sending."; } else { echo "Email Can Not Send."; } ?> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท