I am trying to send smtp email using javascript in html contact page
I am able to send email when I hardcode email id and password but when I generate SecureToken using https://smtpjs.com/, it is not sending email BTW it shows the successful THEN part message “mail sent successfully” (check below code)
I am volunteering to do this work for non-profit org, so there isn’t much options get personal help thank you
====== Email is working with below code (with out SecureToken) =========================
<script type="text/javascript">
function sendEmail() {
var number=document.getElementById('number').value;
var sname=document.getElementById('name').value;
var semail=document.getElementById('semail').value;
var message=document.getElementById('message').value;
var smsg='<html><strong>From :</strong>' + sname + '<br/><strong>Contact :</strong>' + number + '<br/><strong>Email :</strong>' + semail +'<br/><strong>Message:</strong>' + message + '</html>';
Email.send({
Host: "smtp.gmail.com",
Username:'siteEmailID@gmail.com',
Password:'gmailpassword',
To : 'siteEmailID@gmail.com',
From : "siteEmailID@gmail.com",
Subject : "Website Email",
Body : smsg
}).then(
message => alert("mail sent successfully")
);
}
</script>
=============== But not working with the SecureToken =======================
<script type="text/javascript">
function sendEmail() {
var number=document.getElementById('number').value;
var sname=document.getElementById('name').value;
var semail=document.getElementById('semail').value;
var message=document.getElementById('message').value;
var smsg='<html><strong>From :</strong>' + sname + '<br/><strong>Contact :</strong>' + number + '<br/><strong>Email :</strong>' + semail +'<br/><strong>Message:</strong>' + message + '</html>';
Email.send({
SecureToken : "11xxxxxxx-81xx-4fxx-a7xx-e8xxxxxxxeea",
To : 'siteEmailID@gmail.com',
From : "siteEmailID@gmail.com",
Subject : "Website Email",
Body : smsg
}).then(
message => alert("mail sent successfully")
);
}
</script>