Reputation: 13
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
Reputation: 531
I suggest using PHPMailer instead of writing your own code for sending attachments with your emails.
Upvotes: 3