السلام عليكم ورحمة الله وبركاته
طلبي هو :
طريقة المرفقات مع نموذج اتصل بنا إن امكن
وشكراً للجميع
السلام عليكم ورحمة الله وبركاته
طلبي هو :
طريقة المرفقات مع نموذج اتصل بنا إن امكن
وشكراً للجميع
السلام عليكم
شوف اخي
هتعمل حقل لرفع المرفق واسمه مثلا upfile
وطبعا انت عندك صفحة التحقق من المرسل ثم ارسال الرساله
ضع هذا الكود قبل داله الارسال
ملحوظه : المتغيرات mail_headers " غيره الى ما يخص متغير الهيدر حقك..
mail_body غيره الى ما يخص تنسيق الرساله
message هذا متغير الرساله كلها الذي تضعه في الداله . غيره كما هوه عندك
بالطبع هذا ما يخص المرفقات فقط .. اذا اردت الكود كاملا فاخبرنيكود PHP:
if (isset($_FILES['file']))
{
$tmp_name = $_FILES['file']['tmp_name'];
$type = $_FILES['file']['type'];
$upfile = $_FILES['file']['name'];
$size = $_FILES['file']['size'];
if(is_uploaded_file($tmp_name)){
$f = 1;
$file = fopen($tmp_name,'rb');
$data = fread($file,filesize($tmp_name));
fclose($file);
$data = chunk_split(base64_encode($data));
$mail_headers .= "(anti-spam-content-type:) (anti-spam-multipart/mixed);\r\n" .
" boundary=\"{$mime_boundary}\"";
$message = "توجد مرفقات مع هذه الرساله..\n\n" .
"--{$mime_boundary}\n" .
"(anti-spam-content-type:) text/html; charset=\"windows-1256\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$mail_body . "\n\n";
$message .= "--{$mime_boundary}\n" .
"(anti-spam-content-type:) {$type};\n" .
" name=\"{$name}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
}
__________________
سبحان الله وبحمده سبحان الله العظيم
العضوية يستخدمها اكثر من شخص
Nabeel A. Galal
Hawk Eye
nabeel.galal AT hotmail.com
شكراً لك اخي الكريم
راح اجربه وارد عليك
كل المحاولات عندي فشلت
ياليت توضح اكثر لي لانه
لما اضبطته على الشكل المناسب لي تصل الرساله ويذكر ان فيها مرفقات ولاكن المرفقات لا تظهر وتظهر بدالها رموز غيربه
مثل كذا
NMvJx9uydujPP/+pAIdYQP/KWPaiA/bHBOPh3f//xXMzAP/UAJNKAPauBNXPyNilSbNgAP/fAPbS
Art5APaHAPbZAP/SDNeED4pSEZdTBsagcezQNP/RKf/fOurDUPC/WP/XRruie/Hx8O/Ec+reC+ad
حصلت كود ممكن يفيد الجميع
وهو ضبط معاي ولله الحمد
شكراً لك اخي الكريم على مساعدتك
كود PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>E-mail with Attachment</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){
// we'll begin by assigning the To address and message subject
$to="somebody@example.com";
$subject="E-mail with attachment";
// get the sender's name and email address
// we'll just plug them a variable to be used later
$from = stripslashes($_POST['fromname'])."<".stripslashes($_POST['fromemail']).">";
// generate a random string to be used as the boundary marker
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
// store the file information to variables for easier access
$tmp_name = $_FILES['filename']['tmp_name'];
$type = $_FILES['filename']['type'];
$name = $_FILES['filename']['name'];
$size = $_FILES['filename']['size'];
// here we'll hard code a text message
// again, in reality, you'll normally get this from the form submission
$message = "Here is your file: $name";
// if the upload succeded, the file will exist
if (file_exists($tmp_name)){
// check to make sure that it is an uploaded file and not a system file
if(is_uploaded_file($tmp_name)){
// open the file for a binary read
$file = fopen($tmp_name,'rb');
// read the file content into a variable
$data = fread($file,filesize($tmp_name));
// close the file
fclose($file);
// now we encode it and split it into acceptable length lines
$data = chunk_split(base64_encode($data));
}
// now we'll build the message headers
$headers = "From: $from\r\n" .
"(anti-spam-(anti-spam-mime-version:)) 1.0\r\n" .
"(anti-spam-(anti-spam-content-type:)) (anti-spam-(anti-spam-multipart/mixed));\r\n" .
" boundary=\"{$mime_boundary}\"";
// next, we'll build the message body
// note that we insert two dashes in front of the
// MIME boundary when we use it
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"(anti-spam-(anti-spam-content-type:)) text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
// now we'll insert a boundary to indicate we're starting the attachment
// we have to specify the content type, file name, and disposition as
// an attachment, then add the file content and set another boundary to
// indicate that the end of the file has been reached
$message .= "--{$mime_boundary}\n" .
"(anti-spam-(anti-spam-content-type:)) {$type};\n" .
" name=\"{$name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
// now we just send the message
if (@mail($to, $subject, $message, $headers))
echo "Message Sent";
else
echo "Failed to send";
}
} else {
?>
<p>Send an e-mail with an attachment:</p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"
enctype="multipart/form-data" name="form1">
<p>From name: <input type="text" name="fromname"></p>
<p>From e-mail: <input type="text" name="fromemail"></p>
<p>File: <input type="file" name="filename"></p>
<p><input type="submit" name="Submit" value="Submit"></p>
</form>
<?php } ?>
</body>
</html>
مبارك لك حل مشكتلك
ولكن نفس الفكرتين متطابقة .. ربما لاني لم اضع النموذج كاملا فاصبح هناك خلل .. على العموم شكرا لك لوضعك الحل
__________________
سبحان الله وبحمده سبحان الله العظيم
العضوية يستخدمها اكثر من شخص
Nabeel A. Galal
Hawk Eye
nabeel.galal AT hotmail.com
اخي الكريم hawkeye
ممكن تساعدني بخصوص الكود اللي انا وضعته
حصلت معاي مشكله وهي
اولاً الكود ممتاز ويرسل المرفقات ولاكن لا يرسل الرساله الا اذا كانت تحتوي على مرفق
وهذا مستحيل لان مو كل واحد راح يرسلي رساله راح يضع فيها مرفقات
يا اخوان بما انو الموضوع مفتوح بخصوص الدالة mail وخواتها ... مين بعرف كيف نخلي الايمل يصل مباشرة على الانبوكس وبدون ما يروح على الجنك ميل .. بحثت بالانترنت وكل يوصي انو اذا بدي هالشي بس لازم استعمل STMP لارسال بريد يصل للانبوكس بدون مشاكل ... لكن ما اعرف كيف استعملو يعني ما كان كود عملي !!
مين بقدر يساعدنا حبايبي ؟
__________________
EbNCaNa اخوكم ابن قانا
[درس] قائمة بريدية بأسهل الطرق بواسطة PHP
[توقيعك يجب أن لا يكون أطول من 400 حرف يتضمن تجاوز كود المنتدى] - الى متى المعاناة يا حضرة الأدارة ؟
اخي ابن قاناكود PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>E-mail with Attachment</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){
// we'll begin by assigning the To address and message subject
$to="somebody@example.com";
$subject="E-mail with attachment";
// get the sender's name and email address
// we'll just plug them a variable to be used later
$from = stripslashes($_POST['fromname'])."<".stripslashes($_POST['fromemail']).">";
// generate a random string to be used as the boundary marker
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
// store the file information to variables for easier access
$tmp_name = $_FILES['filename']['tmp_name'];
$type = $_FILES['filename']['type'];
$name = $_FILES['filename']['name'];
$size = $_FILES['filename']['size'];
// here we'll hard code a text message
// again, in reality, you'll normally get this from the form submission
$message = "Here is your file: $name";
// if the upload succeded, the file will exist
if (file_exists($tmp_name)){
// check to make sure that it is an uploaded file and not a system file
if(is_uploaded_file($tmp_name)){
// open the file for a binary read
$file = fopen($tmp_name,'rb');
// read the file content into a variable
$data = fread($file,filesize($tmp_name));
// close the file
fclose($file);
// now we encode it and split it into acceptable length lines
$data = chunk_split(base64_encode($data));
}
// now we'll build the message headers
$headers = "From: $from\r\n" .
"(anti-spam-(anti-spam-(anti-spam-mime-version:))) 1.0\r\n" .
"(anti-spam-(anti-spam-(anti-spam-content-type:))) (anti-spam-(anti-spam-(anti-spam-multipart/mixed)));\r\n" .
" boundary=\"{$mime_boundary}\"";
// next, we'll build the message body
// note that we insert two dashes in front of the
// MIME boundary when we use it
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"(anti-spam-(anti-spam-(anti-spam-content-type:))) text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
// now we'll insert a boundary to indicate we're starting the attachment
// we have to specify the content type, file name, and disposition as
// an attachment, then add the file content and set another boundary to
// indicate that the end of the file has been reached
$message .= "--{$mime_boundary}\n" .
"(anti-spam-(anti-spam-(anti-spam-content-type:))) {$type};\n" .
" name=\"{$name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
// now we just send the message
}
if (@mail($to, $subject, $message, $headers))
echo "Message Sent";
else
echo "Failed to send";
} else {
?>
<p>Send an e-mail with an attachment:</p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"
enctype="multipart/form-data" name="form1">
<p>From name: <input type="text" name="fromname"></p>
<p>From e-mail: <input type="text" name="fromemail"></p>
<p>File: <input type="file" name="filename"></p>
<p><input type="submit" name="Submit" value="Submit"></p>
</form>
<?php } ?>
</body>
</html>
الكلاس المرفق جربه وهو سيعمل ان شاء الله
__________________
سبحان الله وبحمده سبحان الله العظيم
العضوية يستخدمها اكثر من شخص
Nabeel A. Galal
Hawk Eye
nabeel.galal AT hotmail.com
للاسف اخي hawkeye
الرساله تصل بدون مرفقات ولاكن الان المرفقات لا تصل بشكل صحيح وتظهر الرساله التالية
كود PHP:
This is a multi-part message in MIME format.
--==Multipart_Boundary_x9106d146faec44478df75d022c232511x
(anti-spam-(anti-spam-(anti-spam-(anti-spam-(anti-spam-content-type:))))) text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Here is your file: download.gif
--==Multipart_Boundary_x9106d146faec44478df75d022c232511x
(anti-spam-(anti-spam-(anti-spam-(anti-spam-(anti-spam-content-type:))))) image/gif;
name="download.gif"
Content-Transfer-Encoding: base64
R0lGODlhFAAUALMAANjs1l28ZvD37064W3nEfMHhvuPx4oXJh7XcsqjWp8zmyje1Up3Sm2vAcQ2x
S////yH5BAAAAAAALAAAAAAUABQAAASH8EmJnL32zD1L++DHcKRinqZAbgmGEevEuFcTSwaj77py
PwIeD/Cb0Rw2EoFopNkKiM1ikTs6DoAFbJINZGkLxZS4qTQqmHDAQea0Dq0LouGIxg6OBD6PH/3W
CAkIFRoccBsCAQsFLQFueElcCxYBKht0DgMkAoKWGwMOkwMhpKSgYZNWR2ERADs=
--==Multipart_Boundary_x9106d146faec44478df75d022c232511x--
اخوي الطالب ممكن نعرف اي جزء مسؤول عن عدم اعتبار الرسالة سبام ... وبالتالي ارسالها للانبوكس ... ؟
__________________
EbNCaNa اخوكم ابن قانا
[درس] قائمة بريدية بأسهل الطرق بواسطة PHP
[توقيعك يجب أن لا يكون أطول من 400 حرف يتضمن تجاوز كود المنتدى] - الى متى المعاناة يا حضرة الأدارة ؟
لا اعلم يا اخي و اللي يفيدك اكثر هو اللي وضع الكلاس الاخ hawkeye
وياليت بعد يضوح لنا ماهو التعديل اللي قام به في الكود كاملاً
جرب الان اخي
كود PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>E-mail with Attachment</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){
// we'll begin by assigning the To address and message subject
$to="somebody@example.com";
$subject="E-mail with attachment";
// get the sender's name and email address
// we'll just plug them a variable to be used later
$from = stripslashes($_POST['fromname'])."<".stripslashes($_POST['fromemail']).">";
// generate a random string to be used as the boundary marker
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
// store the file information to variables for easier access
$tmp_name = $_FILES['filename']['tmp_name'];
$type = $_FILES['filename']['type'];
$name = $_FILES['filename']['name'];
$size = $_FILES['filename']['size'];
// here we'll hard code a text message
// again, in reality, you'll normally get this from the form submission
$message = "Here is your file: $name";
$headers = "From: $from\r\n" .
"(anti-spam-(anti-spam-(anti-spam-(anti-spam-mime-version:)))) 1.0\r\n" .
"(anti-spam-(anti-spam-(anti-spam-(anti-spam-content-type:)))) (anti-spam-(anti-spam-(anti-spam-(anti-spam-multipart/mixed))));\r\n" .
" boundary=\"{$mime_boundary}\"";
// next, we'll build the message body
// note that we insert two dashes in front of the
// MIME boundary when we use it
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"(anti-spam-(anti-spam-(anti-spam-(anti-spam-content-type:)))) text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
// if the upload succeded, the file will exist
if (file_exists($tmp_name)){
// check to make sure that it is an uploaded file and not a system file
if(is_uploaded_file($tmp_name)){
// open the file for a binary read
$file = fopen($tmp_name,'rb');
// read the file content into a variable
$data = fread($file,filesize($tmp_name));
// close the file
fclose($file);
// now we encode it and split it into acceptable length lines
$data = chunk_split(base64_encode($data));
}
// now we'll build the message headers
// now we'll insert a boundary to indicate we're starting the attachment
// we have to specify the content type, file name, and disposition as
// an attachment, then add the file content and set another boundary to
// indicate that the end of the file has been reached
$message .= "--{$mime_boundary}\n" .
"(anti-spam-(anti-spam-(anti-spam-(anti-spam-content-type:)))) {$type};\n" .
" name=\"{$name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
} // now we just send the message
if (@mail($to, $subject, $message, $headers))
echo "Message Sent";
else
echo "Failed to send";
} else {
?>
<p>Send an e-mail with an attachment:</p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"
enctype="multipart/form-data" name="form1">
<p>From name: <input type="text" name="fromname"></p>
<p>From e-mail: <input type="text" name="fromemail"></p>
<p>File: <input type="file" name="filename"></p>
<p><input type="submit" name="Submit" value="Submit"></p>
</form>
<?php } ?>
</body>
</html>
__________________
سبحان الله وبحمده سبحان الله العظيم
العضوية يستخدمها اكثر من شخص
Nabeel A. Galal
Hawk Eye
nabeel.galal AT hotmail.com
اخي ابن قانا
المواقع تختلف .. فمنها ما يتطلب تعديل في الهيدرز فقط ومنها ما يتطلب اكثر من ذلك
فقط قم بتجربه الكلاس الذي ارفقته واذا عمل معك ساقوم بالشرح
عذرا لضيق الوقت حاليا
اخي الطالب .. الامر بسيط
انت كنت تضع داله الارسال داخل شرط اذا كانت هناك مرفقات .. فقمت باخراجها من الشرط
كذلك كنت تضع الهيدرز داخل الشرط فقمت باخراجهم .. قارن بين الكود المعدل والكود الذي وضعته انت وستعرف الفرق .
__________________
سبحان الله وبحمده سبحان الله العظيم
العضوية يستخدمها اكثر من شخص
Nabeel A. Galal
Hawk Eye
nabeel.galal AT hotmail.com
نفس الخطأ بس بزياده
في السابق كان يرسل بدون مرفقات ويصل بدون اخطأ الان يصل بظهور رساله
--==Multipart_Boundary_xf22461145887a7f786ce1157f1f0ed2dx
(anti-spam-(anti-spam-(anti-spam-(anti-spam-(anti-spam-content-type)))) text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Here is your file:
اما اذا ارسلت رساله بمرفق فيظهر نص طويل جد ولا يفهم منه اي شي