Forum Moderators: coopster

Message Too Old, No Replies

mail attachment using smtp

problem with attachment while using smtp

         

sham1321

5:06 am on Aug 7, 2008 (gmt 0)

10+ Year Member



Hai there,

while i am sending mail using smtp, my attachment is receiving as encrypt type....

if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

// Base64 encode the file data
$data = chunk_split(base64_encode($data));

// Add file attachment to the message
$msg .= "--{$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";
}

i am using mail.php please help me out...

eelixduppy

5:15 am on Aug 7, 2008 (gmt 0)



Before adding the mail headers to the email you are sending out, echo out the headers and make sure they are properly formatted before you put them into the email:


echo $headers; exit;

Also, what OS are you running on? I notice that you are only using newline characters to separate the headers.

sham1321

5:37 am on Aug 7, 2008 (gmt 0)

10+ Year Member



hai eelixduppy .. i am new to php...

i got this after echo $headers
From: somedomain.com
to: samu@example.com
cc:
bcc:
subj:
msg:
attach:phpCF.tmp

header is Array

[edited by: jatar_k at 3:01 pm (utc) on Aug. 7, 2008]
[edit reason] no specifics thanks [/edit]

sham1321

7:07 am on Aug 7, 2008 (gmt 0)

10+ Year Member



i am using windows xp