Jump to content

PHP email attachment shows as a bunch of text data


nsarun

Recommended Posts

Hi everybody.....I am trying email attachments....using PHP. Mail goes, mime boundaries are seen, but the attachment shows up as

 

--==Multipart_Boundary_xea5f7ba2ae0131c78f0053adf34656c8x

Content-Type: image/pjpeg;

name="GreatBlue.jpg"

Content-Disposition: attachment;

filename="GreatBlue.jpg"

Content-Transfer-Encoding: base64

 

/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIf

IiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7

Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozv/wAARCAMcBLADASIA

AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA

 

and so on....

 

--==Multipart_Boundary_xea5f7ba2ae0131c78f0053adf34656c8x--

 

 

I dont know what I am doing wrong......can somebody help me please....  ::)

 

Here is the code.

 

$TO='ftlaudmedgroup@yahoo.com';

$HEADERS ='From: SRF - Ft. Lauderdale <ftlaudmedgroup@yahoo.com>'."\r\n";

$RECEP=$_POST['whoto'] ;

$SUBJECT=$_POST['subject'] ;

$MATTER=$_POST['matter'];

$MATTER = nl2br($MATTER);

$MATTER = stripslashes($MATTER);

// Obtain file upload vars

$fileatt      = $_FILES['fileatt']['tmp_name'];

$fileatt_type = $_FILES['fileatt']['type']; //"application/octet-stream";

$fileatt_name = $_FILES['fileatt']['name'];

 

$SIGNATURE= "Some signature";

 

error_reporting(E_ALL); echo $fileatt."is tmpname".$fileatt_type."is the type and the name is: ".$fileatt_name;

$MATTER.=$SIGNATURE;

 

$file = fopen($fileatt,'rb');

$data = fread($file,filesize($fileatt));

fclose($file);

//$data = chunk_split(base64_encode($data));

 

$semi_rand = md5(time());

$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

 

$HEADERS .= "\nMIME-Version: 1.0\n" .

"Content-Type: multipart/mixed;\n" .

" boundary=\"{$mime_boundary}\"";

 

$email_message .= "This is a multi-part message in MIME format.\n\n" .

"--{$mime_boundary}\n" .

"Content-Type:text/html; charset=\"iso-8859-1\"\n" .

"Content-Transfer-Encoding: 7bit\n\n" .

$MATTER . "\n\n";

 

$data = chunk_split(base64_encode($data));

 

$email_message .= "--{$mime_boundary}\n" .

"Content-Type: {$fileatt_type};\n" .

" name=\"{$fileatt_name}\"\n" .

"Content-Disposition: attachment;\n" .

" filename=\"{$fileatt_name}\"\n" .

"Content-Transfer-Encoding: base64\n\n" .

$data . "\n\n" .

"--{$mime_boundary}--\n";

 

if (mail($TO, $SUBJECT, $email_message, $HEADERS)==TRUE){

.

.

 

} and so on....

 

Thank you all for the help.

 

 

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.