Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. <?php
  2. require_once('./vendor/autoload.php'); //Inclus un autoload qui charge tout les plugins de composer que tu ajoutes
  3. $pos = strrpos($_POST['nom'], " ");
  4. if ($pos != false) {
  5. header("Location: Nos clients.");
  6. echo "Format invalide";
  7. }
  8. if(isset($_POST['submit'])) {
  9.  
  10.  
  11. if(isset($_POST['nom'])){
  12.  
  13. $nom = $_POST['nom'];
  14.  
  15. }
  16. if(isset($_POST['pays'])){
  17.  
  18. $pays = $_POST['pays'];
  19.  
  20. }
  21. if(isset($_POST['societe'])){
  22.  
  23. $societe = $_POST['societe'];
  24.  
  25. }
  26. if(isset($_POST['tel'])){
  27.  
  28. $tel = $_POST['tel'];
  29. }
  30. if(isset($_POST['pays'])){
  31.  
  32. $pays = $_POST['pays'];
  33. }
  34.  
  35.  
  36.  
  37.  
  38.  
  39. //-----------------------------------------------
  40. //DECLARE LES VARIABLES ICI
  41. //-----------------------------------------------
  42. //Ici on appelle le plugin php mailer
  43.  
  44. $phpmailer = new \PHPMailer\PHPMailer\PHPMailer();
  45. $filename = $_FILES["file"]["tmp_name"];
  46. // Set Psmtp ou mail basique
  47. $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
  48. //Enable SMTP debugging
  49. // 0 = off (for production use)
  50. // 1 = client messages
  51. // 2 = client and server messages
  52. // $phpmailer->SMTPDebug = 2;
  53. //Set the hostname of the mail server
  54. $phpmailer->Host = 'smtp.mailtrap.io';
  55. // use
  56. // $mail->Host = gethostbyname('smtp.gmail.com');
  57. // if your network does not support SMTP over IPv6
  58. //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
  59. $phpmailer->Port = 2525;
  60. //Set the encryption system to use - ssl (deprecated) or tls
  61. $phpmailer->SMTPSecure = 'Optional';
  62. //Whether to use SMTP authentication
  63. $phpmailer->SMTPAuth = true;
  64. //Username to use for SMTP authentication - use full email address for gmail
  65. $phpmailer->Username = "c66742f0221526"; //ton mail
  66. //Password to use for SMTP authentication
  67. $phpmailer->Password = "f774e5e1c5d75d"; //ton pass (tkt je regarde pas ^)
  68. //Mail de qui ?
  69. $phpmailer->setFrom('from@example.com', 'First Last');
  70. // réponse a qui
  71. $phpmailer->addReplyTo('replyto@example.com', 'First Last');
  72. //envoyer a qui ?
  73. $phpmailer->addAddress('nadiatech01@gmail.com', 'John Doe');
  74. //Sujet
  75. $phpmailer->Subject = 'PHPMailer sendmail test';
  76. //Message en html
  77. $phpmailer->msgHTML("<h1>Client</h1>");
  78. //Message en texte si le html ne s'affiche pas chez les gens
  79. $message = " Nom: " . $_POST['nom'] . "\r\n Pays: " . $_POST['pays'] . "\r\n tel: " . $_POST['tel'] . "\r\n Societe: " . $_POST['societe']. "\r\n Message: " . $_POST['message'];
  80. $phpmailer->AltBody = $message;
  81. $phpmailer->addAttachment($_FILES['file']['tmp_name'],
  82. $_FILES['file']['name']);
  83. //on envoie ou on affiche une erreur
  84. if (!$phpmailer->send()) {
  85. header('Location: Nos clients.php');
  86.  
  87. } else {
  88. header('Location: demande.html');
  89. }
  90. }
  91.  
  92. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement