Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6382277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:30:07+00:00 2026-05-25T02:30:07+00:00

I have this problem in my web page, I need to send a file

  • 0

I have this problem in my web page, I need to send a file via email to someone, the problem that I have is that the mail arrives without an attachment and a lot of strange characters, I leave you my code:

$boundary='Datos Adjuntos';
$boundary.=" ".md5(time());
//Cabeceras del email               

$headers ="From: Example <name@example.com>\r\n";
$headers .= "Reply-To: <name@example.com>\r\n";
//   $headers .="MIME-Version: 1.0\r\n";   
$headers .="Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n\n";

$body="--". $boundary ."\n";
$body .= "Content-Type: text/html; charset=ISO-8859-1\r\n\n";

$archivo=file_get_contents($dir."/".$handle->file_dst_name);

$archivo=chunk_split(base64_encode($archivo));

//Escritura del archivo adjunto
$body .= $body .$ContenidoString. "--" .$boundary. "\n";
//Content-Type: application/msword; name=\"nombre_archivo\"\r\n
$body .= "Content-Transfer-Encoding: base64\r\n";
$body .=  "Content-Disposition: attachment; filename=\"".$handle->file_dst_name."\"\r\n\n$archivo";

$body = $body . "--" . $boundary ."--";

Correo::Enviar("OPERACION","name@example.com", $body,$headers);

The $ContentString is the html of the email, I use the upload class to upload the file to the server and then send it, I leave you a piece of the email that I receive:
This is after all the other things lik e## e name and ## e content of the email.

–Datos Adjuntos 1c436ca78c5925e7096267f0eae3a7d3 Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=”9cbdf187_3251_42e5_aeaa_84df343a227d_4.pdf” JVBERi0xLjQKJdP0zOEKMSAwIG9iago8PAovQ3JlYXRpb25EYXRlKEQ6MjAxMTA4MTYxNTEyNDIt MDUnMDAnKQovQ3JlYXRvcihQREZzaGFycCAxLjMuMTY4NC1nIFwod3d3LnBk

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:30:08+00:00Added an answer on May 25, 2026 at 2:30 am

    While you would be better to use a pre-built library as people are saying, if for some reason you can’t/don’t want to, you can try this:

    EDITED!!

    // Make a MIME boundary
    $boundary = 'Datos_Adjuntos_'.md5(time());
    
    // Message headers
    $headers  = "From: Example <name@example.com>\r\n";
    $headers .= "Reply-To: <name@example.com>\r\n";
    $headers .= "MIME-Version: 1.0\r\n";   
    $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n\r\n";
    
    // For email clients that don't understand MIME messages
    $body = "This is a multi-part message in MIME format. If you can read this, something went wrong or your mail client doesn't understand MIME messages.";
    
    // HTML content
    $body .= "\r\n--$boundary\r\n";
    $body .= "Content-Type: text/html; charset=\"ISO-8859-1\"\r\n\r\n";
    $body .= $ContenidoString;
    
    // Attachment
    $body .= "\r\n--$boundary\r\n";
    $body .= "Content-Transfer-Encoding: base64\r\n";
    $body .= "Content-Type: application/msword\r\n";
    $body .= "Content-Disposition: attachment; filename=\"$handle->file_dst_name\"\r\n\r\n";
    $body .= chunk_split(base64_encode(file_get_contents("$dir/$handle->file_dst_name")));
    
    // Finish the MIME message
    $body .= "\r\n--$boundary--";
    
    // (Presumably) send the email
    Correo::Enviar("OPERACION","name@example.com",$body,$headers);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a need for a simple html + javascript page that must send
I have this little problem. My client wanted two distinct swf on a web
Weired problem! ASP.NET Session expires instantly. In my web.config I have this session settings:
I have an irritating problem, I'm creating an asp.net web service; this service should
I have this problem I'm hoping someone knows the answer to. I have an
I have this problem that my sites uses alot of ajax and when a
Hello i have the this problem, i need your help to figure out what
I have a small problem developing/optimizing a web page. I know it is good
We have following problem. Developers frequently need to make small changes to our web
I have a login page. In my web.config I setup a loginUrl so that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.