| Current Path : /home/ataenra/www/ATA/INTRANET/GenPDF/3Sonergia/ |
| Current File : /home/ataenra/www/ATA/INTRANET/GenPDF/3Sonergia/SendSonergiaFinal.php |
<?php
//Import PHPMailer classes into the global namespace
//These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require '../../Outils/PHPMailer/src/Exception.php';
require '../../Outils/PHPMailer/src/PHPMailer.php';
require '../../Outils/PHPMailer/src/SMTP.php';
//connexion a la base de donnée
require_once '../../Outils/co.php';
$ID = $_GET['ID'];
//recuperation les informations selon ID en get (page?ID=)
//$ID = $_GET['ID'];
$sth = $dbco->prepare("SELECT * FROM chantier WHERE ID = $ID");
$sth->execute();
$R = $sth->fetch(PDO::FETCH_OBJ);
//recuperation des informations selon IDPAC
$sth2 = $dbco->prepare("SELECT * FROM tablepac WHERE id = '$R->IDPAC'");
$sth2->execute();
$R2 = $sth2->fetch(PDO::FETCH_OBJ);
$destinataire = 'anthony.givry@gmail.com';
//Create an instance; passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
require "../../Outils/comail.php";
//Recipients
$mail->setFrom('ata.enr@gmail.com', 'ATA ENR');
$mail->addAddress(''.$destinataire.'', 'Etude Sonergia'); //Add a recipient
$mail->addReplyTo('ata.enr@gmail.com', 'Information');
$mail->addCC('ata.enr@gmail.com');
//Attachments
$mail->addAttachment('../../../FICHIERS/'.$ID.'/Sonergia/SonergiaFinal'.$ID.'.pdf'); //Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name
//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = 'Finalisation Dossier : '.$R->IDSonergia.'';
$mail->Body = 'Vous trouverez en piece jointe les pieces complementaires du dossier : <b>'.$R->IDSonergia.'</b>';
$mail->send();
$Update = $dbco->prepare('UPDATE chantier SET EtatAides = :Etat WHERE ID = :ID');
$Update->bindvalue(':Etat','Dossier termine');
$Update->bindvalue('ID', $ID);
$Update->execute();
header("location:../../../../index.php/agp");
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
?>