AnoTest

sendEmail

Nov 29th, 2021 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function envoyerMessage(){
  2.     let emailInput = document.getElementById('formMailAdress').value;
  3.     let usernamInput = document.getElementById('formMailAdress').value;
  4.     let messageInput = document.getElementById('formMessage').value;
  5.     var data = {
  6.         service_id: 'service_uhiriw7',
  7.         template_id: 'template_vfhno4w',
  8.         user_id: 'user_RgWgV8UKpxFtbjbgABShp',
  9.         template_params: {
  10.             'username': emailInput,
  11.             'to_name': emailInput,
  12.             'from':'samirbenjalloul@gmail.com',
  13.             'message': messageInput,
  14.  
  15.         }
  16.  
  17.     };
  18.      
  19.     $.ajax('https://api.emailjs.com/api/v1.0/email/send', {
  20.         type: 'POST',
  21.         data: JSON.stringify(data),
  22.         contentType: 'application/json'
  23.        
  24.     }).done(function() {
  25.         // alert('Your mail is sent!');
  26.         Swal.fire({
  27.             icon: "success",
  28.             title: "Success...",
  29.             text: "Mail bien envoyé !!",
  30.           });
  31.  
  32.     }).fail(function(error) {
  33.         // alert('Oops... ' + JSON.stringify(error));
  34.         Swal.fire({
  35.             icon: "error",
  36.             title: "Oops...",
  37.             text: "Erreur hmmmmm.... ???",
  38.           });
  39.     });
  40. }
  41.  
Add Comment
Please, Sign In to add comment