เนื่องจากว่า ผมทำ page ไว้หน้านึง เพื่อส่งเมลติดต่อกลับมาหาเรา
ผมเขียนอย่างนี้ครับ
<table width="80%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#006400" bgcolor="#333333">
<tr>
<td align="center" valign="middle"><form action="send.php" method="post" enctype="multipart/form-data" name="frmMain" id="frmMain">
<table width="600" height="275" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td height="28" colspan="2" align="center" valign="middle"><span class="style3">แบบฟอร์มติดต่อเรา</span><br />
<span class="style2">กรุณาใส่ข้อความให้ครบทุกช่อง ไม่เช่นนั้น ระบบจะไม่ดำเนินการติตด่อมาที่เรา</span></td>
</tr>
<tr>
<td width="80" height="28" align="center" valign="middle" class="style3">หัวเรื่อง</td>
<td width="508" align="left" valign="middle"><input name="txtSubject" type="text" id="txtSubject" size="70" /></td>
</tr>
<tr>
<td height="28" align="center" valign="middle" class="style3">ข้อความ</td>
<td align="left" valign="middle"><textarea name="txtDescription" cols="70" rows="7" id="txtDescription"></textarea></td>
</tr>
<tr>
<td height="34" align="center" valign="middle" class="style3">ชื่อผู้ส่ง</td>
<td align="left" valign="middle"><input name="txtFormName" type="text" size="70" /></td>
</tr>
<tr>
<td height="26" align="center" valign="middle" class="style3">Email ผู้ส่ง</td>
<td height="26" align="left" valign="middle"><input name="txtFormEmail" type="text" size="70" /></td>
</tr>
<tr>
<td align="center" valign="middle" class="style3">ส่งรูป</td>
<td height="26" align="left" valign="middle"><input type="hidden" name="MAX_FILE_SIZE" value="50000000" />
<input type="file" name="fileupload" /></td>
</tr>
<tr>
<td colspan="2" align="center" valign="middle"><span class="style1">สำคัญเป็นอย่างมากโปรดอ่านก่อน</span><br />
<span class="style4">เนื่องจากทางเวปเจอเมลขยะเป็นจำนวนมาก<br />
ดังนั้น หากการติดต่อนั้นไม่มีข้อความที่่เกี่ยวข้องกับสินค้าหรือบริการ ที่เกี่ยวข้องกับการตกแต่งรถยนต์<br />
ทางเวปจะลบทิ้งทันที โดยจะไม่เปิดอ่าน และจะไม่มีการตอบกลับ</span><br />
<input type="reset" name="Reset" value="เริ่มใหม่" />
<input type="submit" name="Submit" value="ส่งเมล" /></td>
</tr>
</table>
</form></td>
</tr>
</table>
ปัญหามันเกิดขั้นตรงนี้ครับ
คือการส่งเมลติดต่อมาหาเรานั้น หัวเรื่อง เนื้อเรื่อง ส่งได้ปรกติ
แต่ว่าภาพที่ผู้ส่งมานั้นเลือกแล้ว กดส่งแล้ว แต่ภาพนั้น ไม่มาด้วยไม่ทราบว่า เกิดจากสาเหตุอะไร และต่องแก้ไขยังไง โปรดแนะนำด้วยครับ
มาดันครับ เพราะว่าต่องการทำให้สำเร็จจริง ๆ เกิดปัญหาง่าย ๆ แต่คนโง่อย่างผมทำไม่เป็นน่ะครับ
เอา code send.php มาดูหน่อยครับ
เอาที่เคยทำนะครับ
1. อัพโหลดรูปที่แนบไฟล์ไปไว้บนเซิฟเวอร์
2. กำหนดรูปแบบอีเมล์ที่ส่ง ให้เป็น html
รูปที่อับโหลดลงไปจะอยู่ใน sv เรา สินะครับ
อาจจะต้องเอา url ของรูปแนบมากับเมล์ครับ
อ้างถึงจาก: seowizard ใน 03 กุมภาพันธ์ 2012, 07:48:54
เอา code send.php มาดูหน่อยครับ
ผมเขียนอย่างนี้ครับ
<?
$strTo = "[email protected]";
$strSubject = $_POST["txtSubject"];
//$strHeader = "Content-type: text/html; charset=UTF-8"; // or UTF-8 //
$strHeader .= "From: ".$_POST["txtFormEmail"];
$strMessage = nl2br($_POST["txtDescription"].$_POST["txtFormName"]);
$flgSend = @mail($strTo,$strSubject,$strMessage,$strHeader); // @ = No Show Error //
if($flgSend)
{
echo "ส่งอีเมล์เรียบร้อยแล้ว";
}
else
{
echo "ไม่สามารถส่งอีเมล์ได้";
}
?>
ไม่รู้ว่าเป็นเพราะอะไร ทำไมถึงส่งรูปภาพมาทางเมลเราไม่ได้น่ะครับ
อ้างถึงจาก: itportal ใน 03 กุมภาพันธ์ 2012, 09:12:41
เอาที่เคยทำนะครับ
1. อัพโหลดรูปที่แนบไฟล์ไปไว้บนเซิฟเวอร์
2. กำหนดรูปแบบอีเมล์ที่ส่ง ให้เป็น html
อ้างถึงจาก: ganginwpop ใน 03 กุมภาพันธ์ 2012, 09:14:26
รูปที่อับโหลดลงไปจะอยู่ใน sv เรา สินะครับ
อาจจะต้องเอา url ของรูปแนบมากับเมล์ครับ
นั่นแหละครับ ที่ผมทำไม่เป็นน่ะครับ
<?
$strTo = "[email protected]";
$strSubject = $_POST["txtSubject"];
//$strHeader = "Content-type: text/html; charset=UTF-8"; // or UTF-8 //
$strHeader .= "From: ".$_POST["txtFormEmail"];
$strMessage = nl2br($_POST["txtDescription"].$_POST["txtFormName"]);
$flgSend = @mail($strTo,$strSubject,$strMessage,$strHeader); // @ = No Show Error //
if($flgSend)
{
echo "ส่งอีเมล์เรียบร้อยแล้ว";
}
else
{
echo "ไม่สามารถส่งอีเมล์ได้";
}
?>เพิ่มคำสั่ง upload image Ex.(http://php.net/manual/en/function.move-uploaded-file.php) ก่อนส่ง mail นะครับ แล้ว get path image ของรูปมาแสดง และ ส่งเป็น html ครับ
อาจจะคิดไม่ถึงครับ แต่ยังมีอีก 1 วิธี
<a href="mailto:
[email protected]>send</a>
แบบนี้ attach file ได้แน่นอนครับ
อ้างถึงจาก: iamnotkorr ใน 04 กุมภาพันธ์ 2012, 15:53:43
อาจจะคิดไม่ถึงครับ แต่ยังมีอีก 1 วิธี
<a href="mailto:[email protected]>send</a>
แบบนี้ attach file ได้แน่นอนครับ
อันนี้ได้ทดลองแล้วครับ แต่ว่ามันต่อ outlook แทนน่ะครับ
คืออย่ากได้แบบที่มือโปรฯ หน่อยน่ะครับ
อ้างถึงจาก: seowizard ใน 03 กุมภาพันธ์ 2012, 12:39:27
<?
$strTo = "[email protected]";
$strSubject = $_POST["txtSubject"];
//$strHeader = "Content-type: text/html; charset=UTF-8"; // or UTF-8 //
$strHeader .= "From: ".$_POST["txtFormEmail"];
$strMessage = nl2br($_POST["txtDescription"].$_POST["txtFormName"]);
$flgSend = @mail($strTo,$strSubject,$strMessage,$strHeader); // @ = No Show Error //
if($flgSend)
{
echo "ส่งอีเมล์เรียบร้อยแล้ว";
}
else
{
echo "ไม่สามารถส่งอีเมล์ได้";
}
?>
เพิ่มคำสั่ง upload image Ex.(http://php.net/manual/en/function.move-uploaded-file.php) ก่อนส่ง mail นะครับ แล้ว get path image ของรูปมาแสดง และ ส่งเป็น html ครับ
เนื่องจากไม่รู้จริง ๆ ว่าทำยังไว แล้วก็ได้พยายามมาตั่งแต่เช้าแล้ว ก็ยังไม่เข้าใจอยู่ดีครับ ว่าต่องทำยังไง
เอานี่ไปลองครับ
http://webcheatsheet.com/php/send_email_text_html_attachment.php
<?php
//define the receiver of the email
$to = '[email protected]';
//define the subject of the email
$subject = 'Test email with attachment';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: [email protected]\r\nReply-To: [email protected]";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
//read the atachment file contents into a string,
//encode it with MIME base64,
//and split it into smaller chunks
$attachment = chunk_split(base64_encode(file_get_contents('attachment.zip')));
//define the body of the message.
ob_start(); //Turn on output buffering
?>
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>"
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hello World!!!
This is simple text email message.
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<h2>Hello World!</h2>
<p>This is something with <b>HTML</b> formatting.</p>
--PHP-alt-<?php echo $random_hash; ?>--
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: application/zip; name="attachment.zip"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
<?php echo $attachment; ?>
--PHP-mixed-<?php echo $random_hash; ?>--
<?php
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>