parseChunk('reportPDF', $fields, '[+', '+]'); $text = utf8_decode($text); $betreff = "PDF-Datei im Anhang"; $bodytext = "Dies ist eine Mail mit PDF-Anhang"; $name = "Versender"; $email = "pdftest@ihre-domain.de"; $empfaenger = $fields ['email']; $datum = strftime("%e. %B %Y", mktime()); $adresse = $fields ['vorname'] . ' ' . $fields ['name'] . "\r\n"; $adresse .= $fields ['strasse'] . "\r\n"; $adresse .= $fields ['stadt']; $pdf = new FPDF ('P', 'mm', 'A4'); $pdf->Open(); $pdf->SetAutoPageBreak(true); $pdf->SetMargins(20, 20, 20); $pdf->AddPage(); $pdf->SetFont('Arial', '', 12); $pdf->SetXY(20, 50); $pdf->Write(5, utf8_decode($adresse)); $pdf->SetXY(146, 63); $pdf->Cell(0, 5, utf8_decode($datum), 0, 2); $pdf->SetXY(20, 95); $pdf->SetFont('Arial', 'B', 12); $pdf->Cell(0, 5, utf8_decode($betreff)); $pdf->SetXY(20, 110); $pdf->SetFont('Arial', '', 12); $pdf->Write(5, $text); $anhang = $pdf->Output('', 'S'); $pdf->Close(); $mail = new PHPMailer (); $mail->From = $email; $mail->FromName = $name; $mail->AddAddress($empfaenger); $mail->Subject = $betreff; $mail->Body = $bodytext; $mail->AddStringAttachment($anhang, 'anhang.pdf'); // Check if the mail was sent if (!$mail->Send()) { echo "Die Email konnte nicht gesendet werden"; echo "Fehler: " . $mail->ErrorInfo; } return true; }