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 '[email protected]' 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 : "[email protected]",
Password : "My Password",
To : '[email protected]',
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?
I realised if the value of from is different from the value for username, it gives of that error. so I realised or rather presumed since its not actually sent from the users email that seems reasonable to occur so if you need to get the users email just send it together with the body.
I was testing SMTP JS too and realized the from address MUST be an actual email. What elasticemail does is bounce the mail. So if you try this with an existing mail will work just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With