Good day

I'm trying to send a PDF attachment via the mail function.

I'm able to send the attachment, but when it gets to the other end the attachment is not a PDF document.

Looks llike a PDF document, but Adobe can't read it.

Here my code:

$to = 'example2@example.com';

$subject = 'Test email with attachment';

$random_hash = md5(date('r', time()));

$headers = "From: example@example.com\r\nReply-To: example@example.com";

$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";

$attachment = chunk_split(base64_encode(file_get_contents('taghred.pdf')));

What am I missing?

Thanks

Cheers

Ren

    You may have to show us the code where you are attaching the file to the email. (I prefer to use phpMailer or SwiftMailer to handle that kind of stuff, rather than trusting myself to get all those fiddly details right.)

      I guest your right, is there a way to edit my post?

      MOD EDIT: Posts merged and code included in first post above - no need to create a new topic for the same issue.

        regagnon;11036255 wrote:

        What am I missing?

        Looks like about half of your script ;-)

          We probably need to see what you do with $attachment after you create it.

            Write a Reply...