Vous n'êtes pas identifié(e).
Bonjour à tous
Je génère un fichier pdf avec une facture et j'essaye de l'envoyer par mail
mais j'ai le message d'erreur suivant :
Warning: file_get_contents(Invoice.pdf) [function.file-get-contents]: failed to open stream: No such file or directory in /home/aisbeco/public_html/renadaptor/invoice.php on line 98
Language string failed to load: instantiate
Warning: Cannot modify header information - headers already sent by (output started at /home/aisbeco/public_html/renadaptor/invoice.php:98) in /home/aisbeco/public_html/renadaptor/invoice.php on line 130
je vous mets le code que j'utilise :
Merci d'avance de votre aide :
Mon code :
<?php
require('fpdf.php');
# page header
# logo
$pdf = new FPDF(P,pt);
$pdf->AddPage();
$pdf->Image('images/logo.jpg',40,40,235);
$pdf->SetFont('Times','B',12);
# address and other infos
$pdf->SetXY(50,750);$pdf->Cell(0,12,'informatic',0,2);
$pdf->SetFont('Times','',10);
$pdf->SetXY(170,750);
$pdf->Cell(0,12,'adresse',0,2);
$pdf->Cell(0,12,'autres infos',0,2);
# user name and address
$pdf->SetFont('Times','',12);
$pdf->SetXY(320,160);$pdf->Cell(0,12,$_SESSION['Lastname'].' '.$_SESSION['Firstname'],0,2);
$pdf->Cell(0,12,$_SESSION['Address'],0,2);
$pdf->Cell(0,12,$_SESSION['Pcode'].' '.$_SESSION['City'],0,2);
$pdf->SetFont('Times','B',12);$pdf->Cell(20,12,$countries[$_SESSION['Country']],0,1);
# date
$pdf->SetFont('Times','',12);
$pdf->SetXY(370,260);$pdf->Cell(0,20,$_date.' '.date("d/m/Y").'. '.$_dmy);
# content of invoice
$pdf->SetFont('Times','B',16);
$pdf->SetXY(80,350);$pdf->Cell(0,20,$_invoice.' '.$_SESSION['Invoicenr']);
$pdf->SetFont('Times','',12);
$pdf->SetXY(100,405);$pdf->Cell(0,20,$_desc);
$price=substr($_SESSION['Price'],0,-2).'.'.substr($_SESSION['Price'],-2); # format price by inserting a decimal point
$totprice=substr($_SESSION['TotPrice'],0,-2).'.'.substr($_SESSION['TotPrice'],-2); # format TotPrice by inserting a decimal point
#if ($_SESSION['VatAmount']!=0)
if ($_SESSION['Country'] == 'BE')
{$pdf->SetXY(450,405);$pdf->Cell(0,20,$price);
$pdf->SetXY(100,425);$pdf->Cell(100,20,$_vat);
$vatperc=substr($_SESSION['VatPerc'],0,-2).'.'.substr($_SESSION['VatPerc'],-2); # format VatPerc by inserting a decimal point
# $pdf->SetXY(130,425);
$pdf->Cell(100,20,$vatperc.' %');
$vatamount=substr($_SESSION['VatAmount'],0,-2).'.'.substr($_SESSION['VatAmount'],-2); # format VatAmount by inserting a decimal point
$pdf->SetXY(450,425);$pdf->Cell(40,20,$vatamount);
$pdf->SetXY(100,460);$pdf->Cell(100,20,$_total);
$pdf->SetXY(450,460);$pdf->Cell(40,20,$totprice);
}
else
{$pdf->SetXY(450,405);$pdf->Cell(0,20,$totprice);
}
$pdf->SetX(483);$pdf->Cell(0,20,'euros');
$doc =$pdf->Output('Invoice.pdf','S');
#--------------------- L'envoie de la facture par mail------------------------------------------------------------------------------------------------
file_get_contents('Invoice.pdf');
$email = $_SESSION['Email'];
$email = $email.', adresse miail';
require "class.phpmailer.php";
$mail = new PHPmailer();
$mail->IsHTML(true);
$mail->FromName = "Webmaster";
$mail->From='webmaster@monsite.net';
$mail->AddAddress($email, "Subject");
$mail->AddReplyTo('no reply');
$mail->Subject='Your Invoice ';
$mail->Body=($invoice);
$mail->AddStringAttachment($doc, 'Invoice.pdf', 'base64', 'application/pdf');
$mail->Send();
if(!$mail->Send()){
echo $mail->ErrorInfo;
}
else{
echo 'Mail envoyé avec succès';
}
$mail->SmtpClose();
unset($mail);
?>
Hors ligne
file_get_contents('Invoice.pdf');
ne sert à rien, vu que tu ne récupères pas le contenu pour en faire quelque chose.
Invoice.pdf est bien dans le même répertoire que invoice.php ?
Hors ligne
Bonjour
Normalement "Invoice.pdf" est généré dans le même répertoire, et je le récupère pour l'envoyer par mail
a ton avis je dois enlever le "file_get_contents('Invoice.pdf');" ?
Hors ligne