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


امتیاز موضوع:
  • 14 رای - 1.93 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: ارسال فایل با ایمیل
حالت خطی
#7
میشه قسمت اتچ را بیشتر توضیح بدین
کد:
<?php
//define the receiver of the email
$to = 'youraddress@example.com';
//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: webmaster@example.com\r\nReply-To: webmaster@example.com";
//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";
?>

این قسمت را باید چه کنم چزوری مقدار خودم را بهش بد! ادرس فایل را چطوری بدم بهش

$attachment = chunk_split(base64_encode(file_get_contents('attachment.zip')));
 
پاسخ
  


پیام‌های این موضوع
ارسال فایل با ایمیل - توسط Ghoghnus - 07-10-2011، 04:04 PM
RE: ارسال فایل با ایمیل - توسط Ghoghnus - 07-13-2011، 10:38 PM
RE: ارسال فایل با ایمیل - توسط Ghoghnus - 07-14-2011، 12:06 PM
RE: ارسال فایل با ایمیل - توسط Ghoghnus - 07-14-2011، 02:13 PM

موضوعات مشابه ...
موضوع نویسنده پاسخ بازدید آخرین ارسال
  سورس کد فرستادن ایمیل به همراه فایل پیوست (پی اچ پی) Amin_Mansouri 2 9,661 11-10-2014، 09:18 PM
آخرین ارسال: farshadm
  اپلود فایل Ghoghnus 7 9,494 01-28-2013، 11:32 PM
آخرین ارسال: MarMar
  اپلود فایل با نام رندم امیر 0 2,826 08-05-2012، 12:34 PM
آخرین ارسال: امیر
  آپلود فایل تکست a.adhami 5 9,788 07-28-2012، 11:18 AM
آخرین ارسال: Amin_Mansouri
  ارسال اس ام اس a.adhami 2 3,432 07-02-2012، 09:34 PM
آخرین ارسال: Oep
Thumbs Down ایمیل سندر a.adhami 1 3,400 06-19-2012، 11:53 AM
آخرین ارسال: Amin_Mansouri
  سورس کد لاگین کردن به اف تی پی و اپلود فایل(پی اچ پی) Amin_Mansouri 0 4,637 06-17-2012، 09:32 AM
آخرین ارسال: Amin_Mansouri
  سورس کد اپلودر فایل (پی اچ پی) Amin_Mansouri 0 3,413 06-16-2012، 08:54 PM
آخرین ارسال: Amin_Mansouri
  سورس کد خواندن فایل جی زیپ ( پی اچ پی) Amin_Mansouri 0 3,016 06-16-2012، 08:39 PM
آخرین ارسال: Amin_Mansouri
  اجرای PHP از درون فایل های HTML Amin_Mansouri 0 2,921 02-03-2012، 05:56 PM
آخرین ارسال: Amin_Mansouri

پرش به انجمن:


Browsing: 1 مهمان