Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i have got this code - mail with attachment.......... but i get an error

<?php
    $name = "Reviewbox";
    $email = "jmaster@gmail.com";
    $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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
223 views
Welcome To Ask or Share your Answers For Others

1 Answer

You're using “...” instead of quotes "...". Looks like code copied from a web page that transforms quotes into "fancy quotes" and pasted in a text file.

Replace all occurrences of and with ".


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...