• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 41 رای - 2.2 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: سورس کد فرستادن ایمیل به همراه فایل پیوست (پی اچ پی)
حالت خطی
#1
درود
سورس زیر که با زبان php نوشته شده است یاد میگیرید که چگونه ایمیل بفرستید و همراش حتی فایل پیوست کنید.
Email with attachment
کد:
Email with attachment<?php
$fileatt = ""; // Path to the file                  
$fileatt_type = "application/octet-stream"; // File Type
$fileatt_name = ""; // Filename that will be used for the file as the attachment $email_from = ""; // Who the email is from
$email_subject = ""; // The Subject of the email
$email_message = ""; // Message that the email has in it $email_to = ""; // Who the email is too $headers = "From: ".$email_from; $semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
    
$headers .= "\nMIME-Version: 1.0\n" .
            "Content-Type: multipart/mixed;\n" .
            " boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" .
                "--{$mime_boundary}\n" .
                "Content-Type:text/html; charset=\"iso-8859-1\"\n" .
               "Content-Transfer-Encoding: 7bit\n\n" .
$email_message . "\n\n"; /* First File*/
$fileatt = ""; // Path to the file                  
$fileatt_type = "application/octet-stream"; // File Type
$fileatt_name = ""; // Filename that will be used for the file as the attachment $file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$data = chunk_split(base64_encode($data)); $email_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";
unset($data)
unset($file)
unset($fileatt)
unset($fileatt_type)
unset($fileatt_name)
/* Second File */ $fileatt = ""; // Path to the file                  
$fileatt_type = "application/octet-stream"; // File Type
$fileatt_name = ""; // Filename that will be used for the file as the attachment $file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$data = chunk_split(base64_encode($data)); $email_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";
unset($data)
unset($file)
unset($fileatt)
unset($fileatt_type)
unset($fileatt_name)
/* End of File Config */ // To add more files just copy the file section again, but make sure they are all one after the other! If they are not it will not work!
$ok = @mail($email_to, $email_subject, $email_message, $headers); if($ok) {
echo "<font face=verdana size=2>The file was successfully sent!</font>";
} else {
die("Sorry but the email could not be sent. Please go back and try again!");
}
?>
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
  


پیام‌های این موضوع
سورس کد فرستادن ایمیل به همراه فایل پیوست (پی اچ پی) - توسط Amin_Mansouri - 06-17-2012، 09:37 AM

موضوعات مشابه ...
موضوع نویسنده پاسخ بازدید آخرین ارسال
  سورس کد فرم ثبت نام کاربر (PHP) Amin_Mansouri 3 10,779 11-10-2014، 09:11 PM
آخرین ارسال: farshadm
  سورس کد ساخت اعداد تصادفی (پی اچ پی) Amin_Mansouri 2 6,695 09-11-2014، 07:22 AM
آخرین ارسال: mahfelsoft
  سورس کد فاکتوریل php Amin_Mansouri 1 6,288 06-12-2014، 12:22 AM
آخرین ارسال: Amin_Mansouri
  سورس کد پرینت اعداد و حروف به صورت وارونه Amin_Mansouri 0 2,911 06-09-2014، 11:10 AM
آخرین ارسال: Amin_Mansouri
  سورس کد پرینت میانگین 5 عدد در PHP Amin_Mansouri 0 3,139 06-08-2014، 11:51 PM
آخرین ارسال: Amin_Mansouri
  سورس کد پرینت تعداد مقسوم علیه یک عدد PHP Amin_Mansouri 0 4,257 06-08-2014، 11:36 PM
آخرین ارسال: Amin_Mansouri
  اپلود فایل Ghoghnus 7 9,494 01-28-2013، 11:32 PM
آخرین ارسال: MarMar
  سورس کد صفحه لاگین و ثبت نام کاربر (php) Amin_Mansouri 0 7,755 11-30-2012، 12:15 PM
آخرین ارسال: Amin_Mansouri
  سورس کد حذف ویرایش و اضافه کردن در دیتابیس (ساده) (php( Amin_Mansouri 0 8,118 09-04-2012، 11:37 PM
آخرین ارسال: Amin_Mansouri
  اپلود فایل با نام رندم امیر 0 2,826 08-05-2012، 12:34 PM
آخرین ارسال: امیر

پرش به انجمن:


Browsing: 1 مهمان