php - Pear Mail sends email without attachment -


i trying send mail using php pear mail attached files. reading text file filenames , using create filepath can attach file per pear addattachment() syntax. when receive mail has no attachments.

my code

function sendmail() {     $pdf_filename = file_get_contents("/tmp/uploads/filelog/pdffiles.txt");     $csv_filename = file_get_contents("/tmp/uploads/filelog/csvfiles.txt");      $text = 'text version of email';     $html = '<html><body>html version of email</body></html>';     $csv_file = '/tmp/uploads/csv/' . $csv_filename;     $pdf_file = '/tmp/uploads/pdf/' . $pdf_filename;     $crlf = "\n";     $hdrs = array (             'from' => 'you@yourdomain.com',             'subject' => 'test mime message'      );      $mime = new mail_mime ( array (             'eol' => $crlf      ) );     $mime->settxtbody ( $text );     $mime->sethtmlbody ( $html );     $mime->addattachment ( $csv_file, 'text/csv' );     $mime->addattachment ( $pdf_file, 'application/pdf' );     $body = $mime->get ();     $hdrs = $mime->headers ( $hdrs );     $mail = & mail::factory ( 'mail' );     $mail->send ( 'user@sippycup.co.uk', $hdrs, $body );     if (pear::iserror ( $mail )) {         echo ("<p>" . $mail->getmessage () . "</p>");     } else {          echo ("<p>message sent!</p>");     } } sendmail(); 

why not working? though have confirmed both files exist on server.

there whitespaces being generated, simple trim() fixed problem.

$csv_trimed = trim($csv_file); $pdf_trimed = trim($pdf_file); . . . . .  $mime->addattachment ( $csv_trimed, 'text/csv' ); $mime->addattachment ( $pdf_trimed, 'application/pdf' ); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -