2

emailmefile

emailmefile
SYNOPSIS

emailmefile($subject, $msg, $file, $filename=false, $from=false, $to=false)

CODE
  1. require_once 'filemimetype.php';
  2.  
  3. function emailmefile($subject, $msg, $file, $filename=false, $from=false, $to=false) {
  4.     global $webmaster, $mailer;
  5.  
  6.     if (!$from) {
  7.         $from = $webmaster;
  8.     }
  9.     if (!$to) {
  10.         $to = $webmaster;
  11.     }
  12.  
  13.     $filetype=file_mime_type($file);
  14.  
  15.     if (!$filetype) {
  16.         return false;
  17.     }
  18.  
  19.     $filedata=@file_get_contents($file);
  20.  
  21.     if (!$filedata) {
  22.         return false;
  23.     }
  24.  
  25.     if (!$filename) {
  26.         $filename=basename($file);
  27.     }
  28.  
  29.     $sep=md5(uniqid('sep'));
  30.     $data=chunk_split(base64_encode($filedata));
  31.  
  32.     $headers = <<<_SEP_
  33. From: $from
  34. Return-Path: $from
  35. Content-Type: multipart/mixed; boundary="$sep"
  36. X-Mailer: $mailer
  37. _SEP_;
  38.  
  39.     $body = <<<_SEP_
  40. --$sep
  41. Content-Type: text/plain; charset=utf-8
  42.  
  43. $msg
  44. --$sep
  45. Content-Type: $filetype; name="$filename"
  46. Content-Transfer-Encoding: base64
  47. Content-Disposition: attachment; filename="$filename"
  48.  
  49. $data
  50. --$sep--
  51. _SEP_;
  52.  
  53.     return @mail($to, $subject, $body, $headers);
  54. }
SEE ALSO

emailme, emailhtml, emailtext, emailcrypto

Comments

Your comment:
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip help 2000

Enter a maximum of 2000 characters.
Improve the presentation of your text with the following formatting tags:
[p]paragraph[/p], [b]bold[/b], [i]italics[/i], [u]underline[/u], [s]strike[/s], [quote]citation[/quote], [pre]as is[/pre], [br]line break,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]command[/code], [code=language]source code in c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].