Send email with pdf attachment?

I use PHP's SwiftMailer (swiftmailer.org/): require_once('../lib/swiftMailer/lib/swift_required. Php'); ... $body="Dear $fname,\n\nPlease find attached, an invoice for the period $startDate - $endDate\n\nBest regards,\n\nMr X"; $message = Swift_Message::newInstance('Subject goes here') ->setFrom(array($email => "no-reply@mydomain. Com")) ->setTo(array($email => "$fname $lname")) ->setBody($body); $message->attach(Swift_Attachment::fromPath("../../invoices_unpaid/$id.

Pdf")); $result = $mailer->send($message).

Thank you guys for the help the problem solved :D – Amjad Jul 20 at 11:47 1 You should accept the correct answer! – Eamorr Jul 20 at 11:57.

The attachment doesn't go in the headers! They should only declare the MIME headers: // main header (multipart mandatory) $headers = "From: ". $from.

$eol; $headers . = "MIME-Version: 1.0". $eol; $headers .

= "Content-Type: multipart/mixed; boundary=\"". $separator. "\"".

$eol; // see below $headers . = "Content-Transfer-Encoding: 7bit". $eol; // message $msg = "--".

$separator. $eol; $msg . = "Content-Type: text/html; charset=\"iso-8859-1\"".

$eol; $msg . = "Content-Transfer-Encoding: 8bit". $eol.

$eol; $msg . = $message. $eol.

$eol; // attachment $msg . = "--". $separator.

$eol; $msg . = "Content-Type: application/octet-stream; name=\"". $filename."\"".

$eol; $msg . = "Content-Transfer-Encoding: base64". $eol; $msg .

= "Content-Disposition: attachment". $eol; $msg . = $attachment.

$eol; $msg . = "--". $separator.

"--". $eol; // send message mail($to, $subject, $msg, $headers); Note also that you should NEVER have 2 consecutive line terminations within the headers - SMTP uses a blank line as the seperator between headers and the body. Also, the EOL should NOT be the default on your operating system - it should be the EOL sequence as defined by SMTP - i.e.

CR+LF.

I would suggest that you use PHP Mailer to send emails from your PHP. I've used it with great success on many different configurations. The class has all necessary methods for handling encodings, attachments, custome headers, sending via sendmail, etc., etc.

Ok I will see wut I can do thank you :) – Amjad Jul 20 at 11:20.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions