I want to email a PDF as an attachment that was created using FPDF. My code looks like this, but the attachment never comes through.
I think you have a superfluous command there. You are using the string variant of the Output() command:
$doc = $pdf->Output('test.pdf', 'S');
Then you are performing a file_get_contents() on it:
$attachment = chunk_split(base64_encode(file_get_contents($doc)));
It is not a file, it is a file in a string, as file_get_contents() would return if $doc was a filename.
Just reduce that down to:
$attachment = chunk_split(base64_encode($doc));
Then see if any more errors occur.