I'm trying to make a contact form on my website with SMTP JS. However, when I submit info into the form it's not working outputting error message: "SMTP JS Contact Form Says "Mailbox name not allowed. The server response was: Envelope FROM 'example@example.com' email address not allowed."
Here is my code: HTML:
<form onsubmit="send(); reset(); return false;">
<input placeholder="First Name" required id="first-name"><br>
<input placeholder="Last Name" required id="last-name"><br>
<input placeholder="Email Adress" required id="email"><br>
<button>Submit</button>
</form>
SMTP JS
<script src="https://smtpjs.com/v3/smtp.js"></script>
<script>
var send = function() {
Email.send({
Host : "smtp.elasticemail.com",
Username : "example@example.com",
Password : "My Password",
To : 'example@example.com',
From : document.getElementById("email").value,
Subject : "New Signup!!!",
Body : "And this is the body"
}).then(
message => alert(message)
);
};
</script>
I've tried moving the website to https server as well as localhost. How can I fix this?
Many of the answers here helped point me in the right direction but not fully addressed the problem. The actual answer is the comments:
I put my actual email as Username and From and it worked on the spot. Are you still getting the same error message?
Thank you @user573431
The problem here is that I was sending from any email that was not my own. The From
and ReplyTo
must be your email registered in SMTP.js. Hope this helped someone out!