user1863337
user1863337

Reputation: 13

php mail attachment displayed in mail body in encoded format

iam trying to send mail via php with attachments. the email body is ok but the attachment is displayed in the email body in some encoded format. i have varied the code severally with no success.

this is the attachment as displayed in the email body

JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNlcyAy
IDAgUgovQ29udGVudHMgNCAwIFI+PgplbmRvYmoKNCAwIG9iago8PC9GaWx0ZXIgL0ZsYXRlRGVj
b2RlIC9MZW5ndGggO   

the attachment code

// attachment
$body .= "--".$separator.$eol;
$body .= "Content-Type: application/pdf name=\"".$filename."\"".$eol; 
$body .= "Content-Transfer-Encoding: base64".$eol;
$body .= "Content-Disposition: attachment".$eol.$eol;
$body .= $attachment.$eol;
$body .= "--".$separator."--\n";

please assist, thanks in advance.

Upvotes: 1

Views: 321

Answers (1)

Taimur Khan
Taimur Khan

Reputation: 531

I suggest using PHPMailer instead of writing your own code for sending attachments with your emails.

Upvotes: 3

Related Questions