Jump to content

Search the Community

Showing results for tags 'attachment'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. So, I use mail() to send form data to a client. Works great. Now I am trying to send email to the same client, but with an attachment. I know PHPmailer is preferred, but I'm old school and would like to get this to work. The file I want to send as attachment gets to the far end, but Outlook email displays the binary data instead of having the pdf as an attachment attachment and looks like this: Attached is the Legal Description for 24050240--8f082344de8525de682e9d6aa86aa83f Content-Type: application/pdf; name="Testfile1.pdf" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="Testfile1.pdf" JVBERi0xLjcNJcjIyMjIyMgNMSAwIG9iago8PC9OYW1lcyA4IDAgUi9PdXRsaW5lcyAyIDAgUi9U eXBlL0NhdGFsb2cvUGFnZXMgMyAwIFIvVmVyc2lvbi8xLjc+Pg0KZW5kb2JqCjIgMCBvYmoKPDwv VHlwZS9PdXRsaW5lcy9Db3VudCAwPj4NCmVuZG9iagozIDAgb2JqCjw8L0NvdW50IDEyL0tpZHNb OSAwIFIgNTAgMCBSIDc1IDAgUiA5OSAwIFIgMTI5IDAgUiAxNDUgMCBSIDE2OCAwIFJdL1R5cGUv UGFnZXM+Pg0KZW5kb2JqCjQgMCBvYmoKPDwvU3ViamVjdCgpL1Byb2R1Y2VyKEFzcG9zZS5QZGYg Zm9yIC5ORVQgOS4yLjEpL0NyZWF0aW9uRGF0ZShEOjIwMjQwMTI2MTE1NTQzKS9BdXRob3IoKS9N b2REYXRlKEQ6MjAyNDAxMjYxMTU1NDMpL0NyZWF0b3IoQXNwb3NlIEx0ZC4pL1RpdGxlKE11bHRp cGxlIERvY3VtZW50cyk+Pg0KZW5kb2JqCjggMCBvYmoKPDwvRGVzdHMgMTg0IDAgUj4+DQplbmRv ... ... more of this... The file size is 723709. Here is the code I am using: (I have some echo statements to help me trouble shoot.) Your help appreciated. function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) { echo nl2br ("In funtion mail_attachment: filename = $filename\n"); $file = ($filename); echo nl2br ("In funtion mail_attachment: file = $filename\n"); echo nl2br ("In funtion mail_attachment: path = $path\n"); $file_size = filesize("$path/$file"); echo ("file_size = $file_size\n"); $handle = fopen($path.$filename, "rb"); echo ("handle = $handle"); //$content = file_get_contents($file); $content = fread($handle, $file_size); fclose($handle); $content = chunk_split(base64_encode($content)); echo ("Content = $content\n"); $uid = md5(uniqid(time())); $eol = PHP_EOL; // Headers $header = "From: ".$from_name." <".$from_mail.">".$eol; $header .= "Reply-To: ".$replyto.$eol; $header .= "MIME-Version: 1.0".$eol; $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\""; // // Message $header .= "--".$uid.$eol; $header .= "Content-type:text/plain; charset=iso-8859-1.".$eol; $header .= "Content-Transfer-Encoding: 8bit".$eol.$eol; //$message .= $body.$eol; $message .= "--".$uid.$eol; $message .= "Content-Type: application/pdf; name=\"".$filename."\"".$eol; // use different content types here $message .= "Content-Transfer-Encoding: base64".$eol; $message .= "Content-Disposition: attachment; filename=\"".$filename."\"".$eol; $message .= $content.$eol; $message .= "--".$uid."--"; if (mail($mailto, $subject, $message, $header)) { echo "mail send ... OK"; // or use booleans here } else { echo "mail send ... ERROR!\n"; echo nl2br ("file = $file\n"); echo nl2br ("path.filename = $path.$filename\n"); } }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.