Your IP : 216.73.216.65


Current Path : /home/a/t/a/ataenra/www/ATA/INTRANET/GenPDF/3Sonergia/
Upload File :
Current File : /home/a/t/a/ataenra/www/ATA/INTRANET/GenPDF/3Sonergia/SendSonergia.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 dossier D JOIN projetpacae P ON D.IDprojet = P.IDp JOIN client C ON D.IDclient = C.IDc JOIN simulationprime S ON S.IDps = D.IDprime WHERE ID = $ID"); 

$sth->execute();

$R = $sth->fetch(PDO::FETCH_OBJ);



$destinataire = 'anthony.givry@gmail.com';

//Create an instance; passing `true` enables exceptions

$mail = new PHPMailer(true);



try {

    //Server settings

   // $mail->SMTPDebug = SMTP::DEBUG_SERVER;                      //Enable verbose debug output

    $mail->isSMTP();                                            //Send using SMTP

    $mail->Host       = 'smtp.gmail.com';                     //Set the SMTP server to send through

    $mail->SMTPAuth   = true;                                   //Enable SMTP authentication

    $mail->Username   = 'ata.enr@gmail.com';                     //SMTP username

    $mail->Password   = 'iyjaoyhmexxaiexi';                               //SMTP password

    $mail->SMTPSecure = 'ssl';            //Enable implicit TLS encryption

    $mail->Port       = 465;                                    //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`



    //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/Sonergia'.$ID.'.pdf');         //Add attachments

    //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    //Optional name



    //Content

    $mail->isHTML(true);                                  //Set email format to HTML

    $mail->Subject = 'Etude numero : '.$ID.'';

    $mail->Body    = 'Vous trouverez en piece jointe le dossier numéro : <b>'.$ID.'</b>';



    $mail->send();



    

} catch (Exception $e) {

    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";

}



//UPDATE DE LA BASE DE DONNEES

$Update = $dbco->prepare('UPDATE dossier SET etat = :Etat WHERE ID = :ID');

$Update->bindvalue(':Etat','En traitement');

$Update->bindvalue('ID', $ID);

$Update->execute();



//Mail CLIENT INFO SONERGIA

$mail = new PHPMailer(true);



try {

    //Server settings

   // $mail->SMTPDebug = SMTP::DEBUG_SERVER;                      //Enable verbose debug output

    $mail->isSMTP();                                            //Send using SMTP

    $mail->Host       = 'smtp.gmail.com';                     //Set the SMTP server to send through

    $mail->SMTPAuth   = true;                                   //Enable SMTP authentication

    $mail->Username   = 'ata.enr@gmail.com';                     //SMTP username

    $mail->Password   = 'iyjaoyhmexxaiexi';                               //SMTP password

    $mail->SMTPSecure = 'ssl';            //Enable implicit TLS encryption

    $mail->Port       = 465;                                    //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`



    //Recipients

    $mail->setFrom('ata.enr@gmail.com', 'ATA ENR');

    $mail->addAddress(''.$R->email.'', ''.$R->nom.' '.$R->prenom. '');             

    $mail->addReplyTo('ata.enr@gmail.com', 'Information');

    $mail->addCC(''.$_SESSION['EMAILCOM'].'');

    

    //Attachments

    $mail->addAttachment('../../../FICHIERS/'.$ID.'/Sonergia/Sonergia'.$ID.'.pdf');         

    

    //Content

    $mail->isHTML(true);                                 

    $mail->Subject = 'Avancement de votre Projet : '.$ID.'';

    $mail->Body    = '

    <a>Bonjour '.$R->titre.' '.$R->nom.' '.$R->prenom.'</a><br><br>

    <a>Votre projet a ete soumis au controle de notre partenaire.</a><br>

    <a>Vous trouverez en piece jointe le dossier transmis a Sonergia</a><br><br>

    <a>Lors de l etude des pieces fournies, notre prestataire est susceptible de vous contacter afin de verifier votre identite.</a><br>

    <a>Si votre projet est accepte, vous recevrez un mail de confirmation, validant les montants des aides pouvant vous etre versees.</a><br><br>

    <a>Dans l attente, nous vous souhaitons une bonne journee.</a><br>

    <a>L equipe ATA</a>';

  

    $mail->send();



    

} catch (Exception $e) {

    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";

}



header("location:../../../../index.php/agp");

?>