|
 |
|
เว็บแรกที่หัดเขียนน่ะครับ รบกวนช่วยดูเรื่องการSending Email Upload Form & Attachment หน่อยน่ะครับ |
|
 |
|
|
 |
 |
|
ส่วนนี่เป็นสคริปต์ที่ผมดัดแปลงครับ
<html>
<head>
<title>PitchaClinic.Com PHP Sending Email</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874"><style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style></head>
<body>
<?
$strTo = "[email protected]";
$strSubject = $_POST["txtSubject"];
$strMessage = nl2br($_POST["txtDescription"]);
$strAge = nl2br($_POST["Age"]);
$strGender = nl2br($_POST["Gender"]);
//*** Uniqid Session ***//
$strSid = md5(uniqid(time()));
$strHeader = "";
$strHeader .= "From: ".$_POST["txtFormName"]."<".$_POST["txtFormEmail"].">\nReply-To: ".$_POST["txtFormEmail"]."";
$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";
//*** Attach ***//
for($i=0;$i<count($_FILES["fileAttach"]["name"]);$i++)
{
if($_FILES["fileAttach"]["name"][$i] != "")
{
$strFilesName = $_FILES["fileAttach"]["name"][$i];
$strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"][$i])));
$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 "กำลังส่งข้อมูล ขอบคุณค่ะ";
}
else
{
echo "เกิดข้อผิดพลาดในการส่งข้อมูล กรุณาลองใหม่ภายหลังค่ะ.";
}
?>
</body>
</html>
|
 |
 |
 |
 |
Date :
2009-06-15 17:03:35 |
By :
archeye |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมว่า Web Server ที่คุณใช้อยู่ปิด Script ส่งอีเมล์แน่นอนครับ
|
 |
 |
 |
 |
Date :
2009-06-15 17:20:17 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ เดี๋ยวขอไปจดทะเบียนเว็บแล้วจะกลับมาแจ้งให้ทราบกันอีกทีง้าบว่าใช้ได้หรือไม่ได้อย่างไร
|
 |
 |
 |
 |
Date :
2009-06-15 18:48:53 |
By :
archeye |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ครับตอนนี้ได้จดทะเบียนเว็บเป็นที่เรียบร้อยครับผมพบปัญหาดังนี้ครับ
พอดีมันติดปัญหาตรงนี้คือ เมื่อกรอกข้อมูลลงในช่อง "กรุณาใส่อีเมลของคุณ" ทำยังไงมันก็ไม่ส่งมาเมล์ที่ผมกำหนดไว้น่ะ เลยอยากรบกวน คุณMR.WIN ช่วยตรวจทาน สคริปต์ที่ผมมั่วเขียนให้หน่อย
ส่วนอันนี้เป็นลิงค์ที่เป็นปัญหาอยู่ ที่ว่ามันไม่ส่งมาเมลที่กำหนดซะที
http://www.pitchaclinic.com/contact.html
ตอนนี้ผมได้นำฝากไฟล์รูปมาด้วยครับรบกวนดูคู่กับสคริปต์ด้านล่างนี้ครับ
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Code (PHP)
<?php
<html>
<head>
<title>PitchaClinic.Com PHP Sending Email</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874"><style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style></head>
<body>
<?
$strTo = "[email protected]"; <<<(ตรงนี้เนื่องจากยังทดสอบระบบจึงเป็นเมล์ของผมเอง อนาคตจะให้ส่งข้อมูลไปยังเมล์ [email protected] ครับ)
$strSubject = $_POST["txtSubject"];
$strMessage = nl2br($_POST["txtDescription"]);
$strAge = nl2br($_POST["Age"]); <<<(น่าจะพลาดตรงนี้เพราะผมมั่วครับ)
$strGender = nl2br($_POST["Gender"]); <<<(น่าจะพลาดตรงนี้เพราะมั่วเหมือนเดิมครับ)
//*** Uniqid Session ***//
$strSid = md5(uniqid(time()));
$strHeader = "";
$strHeader .= "From: ".$_POST["txtFormName"]."<".$_POST["txtFormEmail"].">\nReply-To: ".$_POST["txtFormEmail"].""; <<<(น่าจะพลาดตรงนี้ครับเลยไม่สามารถกรอก email แล้วส่งได้)
$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";
//*** Attach ***//
for($i=0;$i<count($_FILES["fileAttach"]["name"]);$i++)
{
if($_FILES["fileAttach"]["name"][$i] != "")
{
$strFilesName = $_FILES["fileAttach"]["name"][$i];
$strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"][$i])));
$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 "กำลังส่งข้อมูล ขอบคุณค่ะ";
}
else
{
echo "เกิดข้อผิดพลาดในการส่งข้อมูล กรุณาลองใหม่ภายหลังค่ะ.";
}
?>
</body>
</html>
?>
รูปนี้เป็นฟอร์มที่ผมออกแบบครับ

รูปนี้เป็นปัญหาที่ผมเจอครับ

รูปนี้เป็นชื่อช่องต่างๆที่ผมได้ตั้งเอาไว้นะครับ

รูปนี้เป็นเมล์ปลายทางของผมเองครับ

  
สุดท้ายนี้ผมขอจุดธูปอัญเชิญเทพใน thaicreate.com มาตอบกระทู้ผมอีกทีนะครับ
             
|
 |
 |
 |
 |
Date :
2009-06-22 20:29:08 |
By :
archeye |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
กระทู้ร่วงแล้ว ขออนุญาติดันแรงๆหนึ่งจึ้กกกกกก
|
 |
 |
 |
 |
Date :
2009-06-23 12:11:07 |
By :
archeye |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขุดๆคร้าบ รอต่อไปอย่างพอมีความหวัง
|
 |
 |
 |
 |
Date :
2009-06-24 15:32:13 |
By :
archeye |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขุดกระทู้ครั้งสุดท้ายแล้วครับ เทพไม่มา
|
 |
 |
 |
 |
Date :
2009-06-26 13:16:42 |
By :
archeye |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แฮ่ๆ ตอนนี้ให้รุ่นนพี่ช่วนน่ะครับ ส่วนตัวก็ยังไม่รู้เรื่องเหมือนเดิม
แต่ยังไงก็ขอขอบคุณทุกท่านที่ช่วยดูให้นะครับ
อันนี้เป็นอันล่าสุดที่แก้ไขแล้วครับ มาอัพเดทให้ชมเผื่อจะมีประโยชน์น่ะครับ

อันนี้รูปตอนกรอกข้อมูลครับ

ส่วนนี่เป็นโค้ดที่รุ่นพี่ดูให้น่ะครับ
Code (PHP)
<?php
<html>
<head>
<title>PitchaClinic.Com PHP Sending Email</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874"><style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style></head>
<body>
<?
$strTo .= "[email protected]";
$strSubject = $_POST["txtSubject"];
$strMessage = nl2br($_POST["txtDescription"]);
$strAge = nl2br($_POST["Age"]);
$strGender = nl2br($_POST["Gender"]);
//*** Uniqid Session ***//
$strSid = md5(uniqid(time()));
// $strHeader = "";
$strHeader .= "From: ".$_POST["txtFormName"]."<".$_POST["txtFormEmail"].">\nReply-To: ".$_POST["txtFormEmail"]." ";
$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";
$strMessage .= " Age ".$strAge."\n\n";
$strMessage .= " Gender ".$strGender."\n\n";
$strMessage .= " send from ".$_POST["txtFormEmail"] ;
$strHeader .= $strMessage."\n\n";
//*** Attach ***//
for($i=0;$i<count($_FILES["fileAttach"]["name"]);$i++)
{
if($_FILES["fileAttach"]["name"][$i] != "")
{
$strFilesName = $_FILES["fileAttach"]["name"][$i];
$strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"][$i])));
$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";
}
}
/*
//echo " strTo $strTo ,strSubject $strSubject ,null, strHeader $strHeader ";
//mail($to, $subject, $message, $headers);
// mail('[email protected]', 'the subject', 'the message', null, '[email protected]');
$ma = mail($strTo,$strSubject,$strMessage,$strHeader);
echo " Status $ma <br>";
*/
$headers = "From: [email protected] \r\n" .
"Reply-To: [email protected] \r\n" .
"X-Mailer: PHP/" . phpversion();
$headers .= $strHeader;
$flgSend = mail($strTo,$strSubject,$strMessage,$headers); // @ = No Show Error //
//echo " $flgSend <br> ";
if($flgSend)
{
echo "กำลังส่งข้อมูล ขอบคุณค่ะ";
echo " <br> <a href=/>Home</a> ";
}
else
{
echo "เกิดข้อผิดพลาดในการส่งข้อมูล กรุณาลองใหม่ภายหลังค่ะ.";
echo " strTo $strTo ,strSubject $strSubject ,strMessage $strMessage, strHeader $strHeader ";
echo " <br> <a href=/>Home</a> ";
}
?>
</body>
</html>
?>
เสร็จแล้วที่เมลปลายทางก็ได้เมล์แบบนี้ล่ะคร้าบ ดีใจสุดๆ

(ปรกติไฟล์รูปที่แนบมาจะเห็นทันที แต่นี่บังเอิญว่าระบบเขาขัดข้องน่ะครับ)
ไว้โอกาศหน้ามีคำถามจะรอรบกวนต่อไปเรื่อยๆนะคร้าบ
|
 |
 |
 |
 |
Date :
2009-07-05 01:57:04 |
By :
archeye |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอโค้ดอีกไฟล์หนึ่งได้อ่ะป่าวคับ ที่เป็น .html อ่ะ
|
 |
 |
 |
 |
Date :
2010-04-23 16:39:31 |
By :
lykub |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|