i have got this code - mail with attachment.......... but i get an error
<?php
$name = "Reviewbox";
$email = "[email protected]";
$to = "$name <$email>";
$from = "Reviewbox ";
$subject = "Here is your attachment";
$fileatt = "doc.pdf";
$fileatttype = "application/pdf";
$fileattname = "newname.pdf";
$headers = "From: $from";
$file = fopen($fileatt, 'rb');
$data = fread($file, filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "
MIME-Version: 1.0
" .
"Content-Type: multipart/mixed;
" .
" boundary="{$mime_boundary}"";
$message = "This is a multi-part message in MIME format.
" .
"-{$mime_boundary}
" .
"Content-Type: text/plain; charset="iso-8859-1
" .
"Content-Transfer-Encoding: 7bit
" .
$message .= "
";
$data = chunk_split(base64_encode($data));
$message .= "–{$mime_boundary}
" .
"Content-Type: {$fileatttype};
" .
" name="{$fileattname}"
" .
"Content-Disposition: attachment;
" .
" filename="{$fileattname}"
" .
"Content-Transfer-Encoding: base64
" .
$data . "
" .
"-{$mime_boundary}-
";
if(mail($to, $subject, $message, $headers)) {
echo "The email was sent.";
}else {echo "There was an error sending the mail.";}
?>
but when i run this code i get an error as "Parse error: syntax error, unexpected '@' in C:wampwwwworkingmail1.php on line 3"..... how to solve this ........
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…