Jump to content

Search the Community

Showing results for tags 'attachment'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 4 results

  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"); } }
  2. Hi! Any suggestions of how to set the // Set email variables & // simple email content for a checkbox to attach a copy of the message to the actual sender? In which case, I obviously do not know in advance to which email address this Cc attachment should be send... Anyone who can help me further? Thx
  3. http://independentrepublicofursum.tk/Become_a_Citizen/ is the page I am having trouble on. Basically what I want to happen here is for the user to download a fillable pdf application, fill it, and upload it. From there the php script will send it to my email so I can review it. My code is... function mail_file($to, $from, $subject, $body, $file) { $boundary = md5(rand()); $header = array( "MIME-Version: 1.0", "Content-Type: multipart/mixed; boundary=\"{$boundary}\"", "From: {$from}" ); $message = array( "--{$boundary}", "Content-Type: text/plain", "Content-Transfer-Encoding: 7bit", '', chunk_split($body), "--{$Boundary}", "Content-Type: {$file['type']}; name=\"{$file['name']}\"", "Content-Disposition: attachment; filename=\"{$file['name']}\"", "Content-Transfer-Encoding: base64", '', chunk_split(base64_encode(file_get_contents($file['tmp_name']))), "--{$boundary}--" ); mail($to, $subject, implode("\r\n", $message), implode("\r\n", $headers)); } Then to send it I use... if (isset($_FILES['file'])) { mail_file('myemail@gmail.com', 'ContactUs@independentrepublicofursum.tk', 'test subject', '', $_FILES['file']); } My form is... <form name="citizenship_application" action="" method="post" enctype="multipart/form-data"> First Name: <input type="text" name="first_name" value="<?php echo $first_name_value; ?>"> <br /> <br /> Last Name: <input type="text" name="last_name" value="<?php echo $last_name_value; ?>"> <br /> <br /> E-Mail:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="text" name="e_mail" value="<?php echo $e_mail_value; ?>"> <br /> <br /> Gender:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="radio" name="sex" value="male" <?php echo $male_pre_select; ?> >Male <input type="radio" name="sex" value="female" <?php echo $female_pre_select; ?> >Female <br /> <br /> <label for="file">Please specify your application file:</label> <br /> <input type="hidden" name="MAX_FILE_SIZE" value="501"> <input type="file" name="file" size="50"> <br /> <br /> <input type="submit" value="Submit Application" name="submit"> &nbsp<?php echo $error; ?> </form> I get two errors, the first one is... Warning: file_get_contents() [function.file-get-contents]: Filename cannot be empty in /home/u418744221/public_html/B­ecome_a_Citizen/index.php on line 38 Line 38 is... chunk_split(base64_encode(fil­e_get_contents($file['tmp_name­']))), My second error is... Warning: implode() [function.implode]: Invalid arguments passed in /home/u418744221/public_html/B­ecome_a_Citizen/index.php on line 43 line 43 is... mail($to, $subject, implode("\r\n", $message), implode("\r\n", $headers)); Really need this finished, ASAP. I can't figure it out, any help appreciated thanks ya'll.
  4. Alright so I have use the PHP mail() function pretty extensively, however for my new site I will need to collect a filled fillable pdf file downloaded from my site, pull it from the files array, then send it to my e-mail so I can look at it later. I can do all of it except attach the .pdf file. How would I go about this? Please don't give me complete code because that is too easy. I wan't to figure it out myself but the tutorials simply don't explain what is happening.
  • 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.