attach file+maile

afshin_66

New Member
با عرض سلام وخسته نباشید
من یک کد برای ارسال ایمیل به همراه attach کردن فایل نوشتم ولی نمی تونم کاراکترها utf_8 به ایمیلی که ارسال می کنم به صورت صحیح دریافت کنم من می خواهم با متغییر msg$ یک رشته فارسی به ایمیلی که می خواهم ارسال کنم
اینم کد من :
PHP:
function send_mail_to_user($to,$from,$subject,$msg,$file)
{

 $fileatt = $_FILES[$file]['tmp_name'];
 $fileatt_type = $_FILES[$file]['type'];
 $fileatt_name = $_FILES[$file]['name']; 
$headers = "From: $from";
if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
//$massge=$msg;
// Add a multipart boundary above the plain message
$message.= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message ."\n\n". $msg;
//.$msg
//print $msg;
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
//}
return @mail($to, $subject, $message, $headers);
//$ok = @mail($to, $subject, $message, $headers);
}
}
اگه می تونید کمکم کنید:rose:
 

afshin_66

New Member
آقا من اصلا کدم درست نشد اگه میشه یه کد بهم بدید که فایل باهاش ایمیل(attach) کنم و بتونم یک متن html باهاش بفرستم(به عنوان متن ایمیل:-?)
 

afshin_66

New Member
با عرض سلام
من از کلاس phpmailer استفاده کردم و خیلیم کارم راه انداخت
ولی من وقتی می خوام یک متن به عنوان پیغام همراه با
فایلم ارسال کنم
مثل
PHP:
$msg="
<head>
<title>subject </title>
 
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
</head>
<body>
<div style=\"direction:rtl\"> <b>فرم درخواست سفارش</b></div><br />
  <table border=\"0\" width=\"100%\" dir=\"rtl\" cellspacing=\"0\" cellpadding=\"0\" >
         <tr>
    <td height=\"30\" width=\"50\">نام و نام خانوادگی :</td>
    <td >".$_REQUEST['name']."</td>   
   </tr>
      <tr>
    <td height=\"30\" >توضیحات:</td>
    <td >".$_REQUEST['comment']."</td>   
   </tr>
    </table>
 </body>
 </html>   ";

در ایمیلم اطلاعات به صورت زیر دریافت می کنم
نام و نام خانوادگي :ط§ظپط´غŒظ† ط§ع©ط±ظ…
توضيحات:غŒط§ ط&shy;ط³غŒظ†
می خواستم بدونم چطور می تونم $_REQUEST[] طوری بفرستم که اونم بطور صحیح دریافت بشه
:rose:با تشکر از راهنمایاتون
 
آخرین ویرایش:

pasargad-ir

Active Member
یعنی شما با عوض کردن "Content-Type: text/plain; charset=\"iso-8859-1\"\n" به UTF-8 باز هم مشکل داری ؟؟؟

خوب از Arabic استفاده کن
 

جدیدترین ارسال ها

بالا