지난 2 년 동안 FPDF를 사용하여 PDF 파일을 생성했습니다. 이 파일이 생성되면 전자 메일로 보내드립니다. 최근에 새 서버에 똑같은 스크립트를 설치했습니다. 하나 또는 다른 이유로 PDF 생성은 오류 메시지가 나타나지 않기 때문에 작동합니다. 내가 이메일로 수신 메시지는 바로 텍스트이며, 다음과 같습니다전자 메일 용 FPDF 생성 첨부 파일이 이상한 문자로 구성됩니다.
--4aca5942d8bd7e7d523d8b2d71c6b1ea-- 또는 --d7582bf6769dd1fa2ee8f05cb04cf445--
모든 메시지가 다릅니다.
스트리핑 된 코드는 다음과 같습니다
require('class.phpmailer.php');
require('fpdf.php');
define('FPDF_FONTPATH','font/');
//Create new PDF
$pdf=new PDF();
$pdf->AliasNbPages();
$pdf->company = $business;
$pdf->SetFont('Arial','',12);
$pdf->SetAutoPageBreak(false);
$pdf->AddPage('P');
// email stuff
$tijd = time();
$datum = date('j-m-Y', $tijd);
$bestandsnaam = $usernameinlog."-".$datum;
$from = "[email protected]".$website;
$subject = "Voorraad mutatie door ".$usernameinlog;
$message = "<p>Zie bijlage voor een mutatieoverzicht.</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 = $bestandsnaam.".pdf";
// encode data (puts attachment in proper format)
$pdfdoc = $pdf->Output("", "S");
$attachment = chunk_split(base64_encode($pdfdoc));
// main header (multipart mandatory)
$headers = "From: ".$from.$eol;
$headers .= "MIME-Version: 1.0".$eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol;
$headers .= "Content-Transfer-Encoding: 7bit".$eol;
$headers .= "This is a MIME encoded message.".$eol.$eol;
// The actual message
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$headers .= $message.$eol.$eol;
// Bijlage
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
$headers .= "Content-Transfer-Encoding: base64".$eol;
$headers .= "Content-Disposition: attachment".$eol.$eol;
$headers .= $attachment.$eol.$eol;
$headers .= "--".$separator."--";
mail($emailemployee, $subject, "", $headers);
사람이 잘못 가고 나는 php.ini 파일에 매개 변수를 놓친 거지 무엇을 알고 있나요? 다시 한번 :이 동일한 코드가 다른 서버에서 작동했기 때문에 일부 설정이 잘못되었거나 무언가를 설치하는 것을 잊어 버렸습니다.
:-) 감사,
알렉스
그것은 모양 일부 해시 값처럼 - 코드를 게시 할 수 있습니까? PDF 생성 또는 전자 메일 전송 스 니펫과 유사합니다. – maialithar
설명을 위해 위의 코드를 추가했습니다! –