Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. $data = file_get_contents("php://input");
  2. $dataAsJson = json_decode($data);
  3. $mail = new PHPMailer(true);
  4. try{
  5. $mail->IsSMTP();
  6. $mail->Mailer = "mail";
  7. $mail->SMTPAuth = true;
  8. $mail->Host = "smtp.ionos.fr";
  9. $mail->Port = 587; //465;
  10. $mail->SMTPDebug = 2;
  11. $mail->SMTPSecure = 'tls';
  12. $mail->Username = "******";
  13. $mail->Password = "******";
  14. $mail->Sender = "tpings@mydomain.fr";
  15. $mail->From = "tpings@mydomain.fr";
  16. $mail->AddAddress($dataAsJson->Email,$dataAsJson->Nom." ".$dataAsJson->Prenom);
  17. $mail->Subject = "Licence";
  18. $mail->FromName = "TPINGS Service";
  19.  
  20. $mail->AddReplyTo('exemple@exemple.com', 'Contact TPINGS' );
  21.  
  22. if($dataAsJson->English == true){
  23. $msg = "myMsg";
  24. $mail->AddAttachment("./uploads/Installation_EN.pdf");
  25. }else{
  26. $msg = "my_FR_msg";
  27. $mail->AddAttachment("./uploads/Installation_FR.pdf");
  28. }
  29.  
  30.  
  31. $mail->MsgHTML($msg);
  32. if(!$mail->Send()) {
  33. http_response_code(500);
  34. echo 'Erreur : ' . $mail->ErrorInfo;
  35. } else {
  36. http_response_code(200);
  37. }
  38. }catch(Exception $e){
  39. echo "Erreur mail : ".$mail->ErrorInfo;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement