I'm making an SMTP-based mail sender. The code that I entered is -
<script>
function sendEmail(){
Email.send({
Host : "smtp.gmail.com",
Username : 'davnit7607@davnitjsr.org',
Password : "*************",
To : 'davnit7607@davnitjsr.org',
From : document.getElementById("email").value,
Subject : "Contact",
Body : "And this is the body"
}).then(
message => alert(message)
);
}
</script>
</body>
</html>
It's not working giving an error -
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required. Learn more at - Fix: Try a different SMTP server: https://elasticemail.com/account#/create-account?r=20b444a2-b3af-4eb8-bae7-911f6097521c
And-
Mailbox name not allowed. The server response was: Envelope FROM 'hi@gmail.com' email address not allowed.
Code
Your errors...
The SMTP server requires a secure connection or the client was not authenticated.
username attribute; you're using Gmail, so you have to provide your Gmail address) and your real password to send emails from your account, right? (That includes the from field.) Gmail also has some extra complications. See this post on how to send emails from Gmail.Mailbox name not allowed. The server response was: Envelope FROM 'hi@gmail.com' email address not allowed.
You tried to send an email from "hi@gmail.com". Do you think it will work? Let's pretend your email is bob@gmail.com. If what you attempted didn't result in an error, that means that I can send an email from your email without your permission! So no, that rightly shouldn't work.
All else aside, please don't try to send emails from the client-side. You realize that if you publish your app everyone can see your email address and password, right?