Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('./vendor/autoload.php'); //Inclus un autoload qui charge tout les plugins de composer que tu ajoutes
- if(isset($_POST['submit'])) {
- //Ici on vérifie si le form est envoyé, si oui on traite tout
- if(isset($_POST['nom'])){
- $nom = $_POST['nom'];
- }
- if(isset($_POST['sujet'])){
- $sujet = $_POST['sujet'];
- }
- if(isset($_POST['message'])){
- $message = $_POST['message'];
- }
- if(isset($_POST['email'])){
- $email = $_POST['email'];
- }
- //-----------------------------------------------
- //DECLARE LES VARIABLES ICI
- //-----------------------------------------------
- //Ici on appelle le plugin php mailer
- $phpmailer = new \PHPMailer\PHPMailer\PHPMailer();
- // Set Psmtp ou mail basique
- $phpmailer-> IsSMTP(); //Quand ton site sera héberger sur un serveur en ligne ça marchera, en attendant faut que tu test avec mailtrap.io par exemple qui te propose un serveur smtp de test gratuitement poue t'es tst à la place de isSendMail tu met
- //Enable SMTP debugging
- // 0 = off (for production use)
- // 1 = client messages
- // 2 = client and server messages
- $phpmailer->SMTPDebug = 2;
- //Set the hostname of the mail server
- $phpmailer->Host = 'smtp.mailtrap.io';
- // use
- // $mail->Host = gethostbyname('smtp.gmail.com');
- // if your network does not support SMTP over IPv6
- //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
- $phpmailer->Port = 2525;
- //Set the encryption system to use - ssl (deprecated) or tls
- $phpmailer->SMTPSecure = 'Optional';
- //Whether to use SMTP authentication
- $phpmailer->SMTPAuth = true;
- //Username to use for SMTP authentication - use full email address for gmail
- $phpmailer->Username = "c66742f0221526"; //ton mail
- //Password to use for SMTP authentication
- $phpmailer->Password = "f774e5e1c5d75d"; //ton pass (tkt je regarde pas ^)
- //Mail de qui ?
- $phpmailer->setFrom('from@example.com', 'First Last');
- // réponse a qui
- $phpmailer->addReplyTo('replyto@example.com', 'First Last');
- //envoyer a qui ?
- $phpmailer->addAddress('nadiatech01@gmail.com', 'John Doe');
- //Sujet
- $phpmailer->Subject = 'PHPMailer sendmail test';
- //Message en html
- $phpmailer->msgHTML("<h1>Contact</h1>");
- //Message en texte si le html ne s'affiche pas chez les gens
- $message = "\r\n Nom: " . $_POST['nom'] . "\r\n Sujet: " . $_POST['sujet'] . "\r\n Email: " . $_POST['email'] . "\r\n Message: " . $_POST['message'];
- $phpmailer->AltBody = $message;
- //on envoie ou on affiche une erreur
- if (!$phpmailer->send()) {
- header('Location: demande.html');
- } else {
- header('Location: demande.html');
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement