Несколько FPDF по почте через переполнение стека

Как я могу динамически отправлять несколько FPDF по почте на PHP?
Я новый пользователь. Сценарии работают отлично индивидуально. mail.php также работает, когда я прикрепляю один pdf. Но мне нужно прикрепить 2 из них к одной и той же почте. Может ли кто-нибудь помочь мне найти выход? Спасибо.

Я прикрепил один из созданных PDF-файлов. Есть еще один с теми же фрагментами кода. Я также приложил скрипт, который использовал для отправки электронного письма.

createpdf.php

<?php
$email_id = $_GET['e'];
$connect=mysqli_connect("localhost", "user",
"password","db") or die("Connection failed1:".mysqli_connect_error());
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',12);
$email_id = $email_id;
$query = $connect->query("SELECT first_name FROM `db` WHERE email_id = '$email_id'");
$array = Array();
while($result = $query->fetch_assoc()){
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40,10,'Dear ' .$result['first_name']. ', This is the 1st doc.');
}

$pdf->Output();

?>

mail.php

    <?php

require('createpdf.php');
$to = $_GET['e'];
$subject = "test";
$message = "<p>Please see the attachment.</p>";

// a random hash will be necessary to send mixed content
$separator = md5(time());

// carriage return type (we use a PHP end of line constant)
$eol = PHP_EOL;

// attachment name
$filename = "test.pdf";

// encode data (puts attachment in proper format)
$pdfdoc = $pdf->Output("", "S");
$attachment = chunk_split(base64_encode($pdfdoc));

// main header
$headers  = "From: X < noreply@test.com >\n";
$headers .= "MIME-Version: 1.0".$eol;
$headers .= "Content-Type: multipart/mixed;
boundary=\"".$separator."\"";

// no more headers after this, we start the body! //

$body = "--".$separator.$eol;
$body .= "Content-Transfer-Encoding: 7bit".$eol.$eol;
$body .= "This is a MIME encoded message.".$eol;

// message
$body .= "--".$separator.$eol;
$body .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$body .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$body .= $message.$eol;

// attachment
$body .= "--".$separator.$eol;
$body .= "Content-Type: application/octet-stream;
name=\"".$filename."\"".$eol;
$body .= "Content-Transfer-Encoding: base64".$eol;
$body .= "Content-Disposition: attachment".$eol.$eol;
$body .= $attachment.$eol;
$body .= "--".$separator."--";

// send message
mail($to, $subject, $body, $headers);

?>

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector