ขอโค้ต form mail ที่ upload รูปหน่อยครับ ขอโค้ต form mail ที่ upload รูปหน่อยครับ..ต้องการ mail
ถ้าเป็นผมจะเอารูปไปเก็บที่ host ก่อนแล้ว ค่อยทำ link รูปมาโชวในรูปแบบ html
Date :
29 ต.ค. 2550 11:04:17
By :
xboy
ก็ผมทำไม่เป็นนิครับ
แถมไม่อยากเก็บภาพเอาไว้ในฐานข้อมูลนิ
Date :
29 ต.ค. 2550 13:15:19
By :
ต้อง
-*-
ไม่ได้ให้เก็บภาพไว้ในฐานข้อมูลครับ ตอนแรกให้อัพโหลดรูปไปที่ ใหนสักที่ก่อน
เช่นอัพไปไว้ ในโฟเดอร์ img/pic.jpg
แล้วพอส่งเมลก็ให้ ลิ้งค์ http://yourserver.com/img/pic.jpg
ถ้าใช้ $post เกรงว่าจะลำบาก ไม่รู้ว่าได้อะป่าว
Date :
29 ต.ค. 2550 13:24:23
By :
xboy
คงจะหมายถึง แนบ ไฟล์รูปภาพไปด้วย
Date :
29 ต.ค. 2550 23:58:03
By :
888
ใช่ๆครับ แต่ผมทำไม่เป็น
แล้วแบบนี้เขียนยากไหมครับ
รึว่าต้องจ้างเขียนครับ
Date :
30 ต.ค. 2550 08:09:35
By :
ต้อง
คงต้องอธิบายกันยาวยืด
ลองศึกษาตัวนี้ดูก่อนสิ
$HTTP_POST_FILES
ไม่ยากเกินพยายาม
Date :
30 ต.ค. 2550 09:59:38
By :
Nicky
ลองเอาตัวนี้ไปใช้จิ ไม่แน่ใจเหมือนกันว่าส่งได้ทุกยี่ห้อหรือเปล่า
----------------------------- example.php----------------------------
<html>
<head>
<title>Mailer Class Example</title>
</head>
<body>
<p>
<?php
define("USE_MAILER",1);
include("mailer.php");
$resMailer = new Mailer;
$resMailer->From("[email protected] ");
$resMailer->To("[email protected] ");
$resMailer->Subject("Hello World!");
$resMailer->Body("Hello World!\n\nHow do you feel today?");
$resMailer->Attach("mailer.php", "text/php", "attachment");
$resMailer->Send();
// echo nl2br($resMailer->GetMail());
?>
</p>
</body>
</html>
----------------------- mailer.php----------------------
<?php
if(!defined("USE_MAILER")) {
echo "Mailer Class: Fatal Error - You cannot access this file directly.";
exit();
}
class Mailer {
var $arrHeaders = array();
var $arrPriority = array("1 (Highest)", "2 (High)", "3 (Normal)", "4 (Low)", "5 (Lowest)");
var $blnReceipt = false;
function AssembleMail () {
if($this->blnReceipt) {
if(isset($this->arrHeaders["Reply-To"])) {
$this->arrHeaders["Disposition-Notification-To"] = $this->arrHeaders["Reply-To"];
}
else {
$this->arrHeaders["Disposition-Notification-To"] = $this->arrHeaders["From"];
}
}
$this->arrHeaders["Mime-Version"] = "1.0";
$this->arrHeaders["X-Mailer"] = "MaresWEB Mailer";
$this->arrHeaders["X-Sender-IP"] = $this->strIP;
reset($this->arrHeaders);
if(count($this->arrAttachmentFilename) == 0) {
$this->arrHeaders["Content-Type"] = "text/plain; charset=" . $this->strCharacterSet . "; format=flowed\n";
$this->arrHeaders["Content-Transfer-Encoding"] = "8bit";
$this->strMail = $this->strBody . "\n\n";
}
else {
$this->arrHeaders["Content-Type"] = "multipart/mixed; boundary=\"" . $this->strBoundary . "\"";
$this->strMail = "This is a MIME encapsulated multipart message - please use a MIME compliant e-mail program to open it.\n\n";
$this->strMail .= "--" . $this->strBoundary . "\n";
$this->strMail .= "Content-Type: text/plain; charset=" . $this->strCharacterSet . "; format=flowed\n";
$this->strMail .= "Content-Transfer-Encoding: 8bit\n\n";
$this->strMail .= $this->strBody . "\n\n";
$this->BuildAttachments();
$this->strMail .= "--" . $this->strBoundary . "--";
}
while(list($strHeaderName,$strHeaderValue) = each($this->arrHeaders)) {
if($strHeaderName != "Subject") {
$this->strHeaders .= $strHeaderName . ": " . $strHeaderValue . "\n";
}
}
}
function Attach($strFilename, $strMIMEType = "", $strDisposition = "attachment") {
if(!is_string($strFilename)) {
echo "Mailer Class: Fatal Error - \"Attachment Filename\" does not contain a string value.";
exit;
}
else {
if(!file_exists($strFilename)) {
echo "Mailer Class: Fatal Error - The file " . $strFilename . " cannot be accessed.";
exit;
}
}
if(!is_string($strMIMEType)) {
echo "Mailer Class: Fatal Error - \"Attachment MIME Type\" does not contain a string value.";
exit;
}
if(!is_string($strDisposition)) {
echo "Mailer Class: Fatal Error - \"Attachment Disposition\" does not contain a string value.";
exit;
}
if($strMIMEType == "") {
$strMIMEType = "application/x-unknown-content-type";
}
$this->arrAttachmentDisposition[] = $strDisposition;
$this->arrAttachmentFilename[] = $strFilename;
$this->arrAttachmentMIMEType[] = $strMIMEType;
}
function BCC($varBCC) {
if(is_array($varBCC)) {
if(count($varBCC) > 0) {
$this->arrHeaders["BCC"] = implode(", ",$varBCC);
}
else {
$this->arrHeaders["BCC"] = $varBCC;
}
}
elseif(is_string($varBCC)) {
$this->arrHeaders["BCC"] = $varBCC;
}
else {
echo "Mailer Class: Fatal Error - \"BCC\" does not contain an array or a string value.";
exit;
}
}
function Body($strBody, $strCharacterSet = "") {
if(!is_string($strBody)) {
echo "Mailer Class: Fatal Error - \"Body\" does not contain a string value.";
exit;
}
if(!is_string($strCharacterSet)) {
echo "Mailer Class: Fatal Error - \"Body Character Set\" does not contain a string value.";
exit;
}
$this->strBody = $strBody;
if($strCharacterSet == "") {
$this->strCharacterSet = "iso-8859-1";
}
else {
$this->strCharacterSet = strtolower($strCharacterSet);
}
}
function BuildAttachments() {
$arrAttachments = array();
$intAttachmentIndex = 0;
for($intCounter = 0; $intCounter < count($this->arrAttachmentFilename); $intCounter++) {
$strFilename = $this->arrAttachmentFilename[$intCounter];
$strBasename = basename($strFilename);
$strSubheader = "--" . $this->strBoundary . "\n";
$strSubheader .= "Content-Type: " . $this->arrAttachmentMIMEType[$intCounter] . "; name=\"" . $strBasename . "\"\n";
$strSubheader .= "Content-Transfer-Encoding: base64\n";
$strSubheader .= "Content-Disposition: " . $this->arrAttachmentDisposition[$intCounter] . "; filename=\"" . $strBasename . "\"\n";
$arrAttachments[$intAttachmentIndex++] = $strSubheader;
$intSize = filesize($strFilename)+1;
$intFilePointer = fopen($strFilename,"r");
$arrAttachments[$intAttachmentIndex++] = chunk_split(base64_encode(fread($intFilePointer,$intSize)));
fclose($intFilePointer);
}
$this->strMail .= implode(chr(13) . chr(10),$arrAttachments);
}
function CC($varCC) {
if(is_array($varCC)) {
if(count($varCC) > 0) {
$this->arrHeaders["CC"] = implode(", ",$varCC);
}
else {
$this->arrHeaders["CC"] = $varCC;
}
}
elseif(is_string($varCC)) {
$this->arrHeaders["CC"] = $varCC;
}
else {
echo "Mailer Class: Fatal Error - \"CC\" does not contain an array or a string value.";
exit;
}
}
function From($strFrom) {
if(!is_string($strFrom)) {
echo "Mailer Class: Fatal Error - \"From\" does not contain a string value.";
exit;
}
$this->arrHeaders["From"] = $strFrom;
}
function GetMail() {
$this->AssembleMail();
$strMail = "To: " . $this->strTo . "\n";
$strMail .= $this->strHeaders . "\n";
$strMail .= $this->strMail;
return $strMail;
}
function Mailer() {
$this->strBoundary = md5(uniqid(rand(),true));
$this->strIP = $_SERVER["REMOTE_ADDR"];
}
function Organization($strOrganization) {
if(!is_string($strOrganization)) {
echo "Mailer Class: Fatal Error - \"Organization\" does not contain a string value.";
exit;
}
$this->arrHeaders["Organization"] = $strOrganization;
}
function Priority($intPriority) {
if(!intval($intPriority)) {
echo "Mailer Class: Fatal Error - \"X-Priority\" does not contain a numeric value.";
exit;
}
else {
if($intPriority < 1 || $intPriority > 5) {
echo "Mailer Class: Fatal Error - \"X-Priority\" contains an illegal value.";
exit;
}
$this->arrHeaders["X-Priority"] = $this->arrPriority[$intPriority - 1];
}
}
function RequestReceipt($blnValue) {
if(!is_bool($blnValue)) {
echo "Mailer Class: Fatal Error - \"Request Receipt\" does not contain a boolean value.";
exit;
}
$this->blnReceipt = $blnValue;
}
function ReplyTo($strReplyTo) {
if(!is_string($strReplyTo)) {
echo "Mailer Class: Fatal Error - \"Reply-To\" does not contain a string value.";
exit;
}
$this->arrHeaders["Reply-To"] = $strReplyTo;
}
function Send() {
$this->AssembleMail();
mail($this->strTo, $this->arrHeaders["Subject"], $this->strMail, $this->strHeaders);
}
function Subject($strSubject) {
if(!is_string($strSubject)) {
echo "Mailer Class: Fatal Error - \"Subject\" does not contain a string value.";
exit;
}
$this->arrHeaders["Subject"] = str_replace("\r", " ", str_replace("\n", " ", $strSubject));
}
function To($varTo) {
if(is_array($varTo)) {
if(count($varTo) > 0) {
$this->strTo = implode(", ", $varTo);
}
else {
$this->strTo = $varTo;
}
}
elseif(is_string($varTo)) {
$this->strTo = $varTo;
}
else {
echo "Mailer Class: Fatal Error - \"To\" does not contain an array or a string value.";
exit;
}
}
}
?>
Date :
30 ต.ค. 2550 11:54:05
By :
888
มีอีกครับ จะเอาไปทดลองไหม
บอกเมลมาครับ จะส่งให้
แต่ ส่งโดยใช้ SMTP ของเครื่อง local ไป Hotmail ไม่ได้นะ
Date :
30 ต.ค. 2550 12:02:44
By :
888
ขอบคุณ คุณ 888 มากๆเลยนะครับ
ใจดีจัง
[email protected]
ขอบคุณมากๆครับ
Date :
30 ต.ค. 2550 16:12:24
By :
ต้อง
Load balance : Server 04