Reputation: 1696
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?
Upvotes: 4
Views: 12356
Reputation: 1696
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!
Upvotes: 0
Reputation: 1
The 2-step verification should be on your gmail account then do email verification in elasticemail website.
Upvotes: 0
Reputation: 1
Host : "smtp.elasticemail.com",
Username : "[email protected]",//username from
elasticemail
Password : "*******",//password from elasticemail SMTP
From : '[email protected]',//username from
elasticemail
To: '[email protected]',//prefered email addresss.
ReplyFrom : document.getElementById("email").value,// user
email displays here in the mail box
Upvotes: -1
Reputation: 527
Two changes needed,
To
and From
emails like below,and then it will work.
<script src="https://smtpjs.com/v3/smtp.js"></script>
<script>
var send = function() {
Email.send({
Host : "smtp.elasticemail.com",
Username : "[email protected]",
Password : "Password for the server created in the Elasticemail",
From : '[email protected]',
To : document.getElementById("email").value,
Subject : "New Signup!!!",
Body : "And this is the body"
}).then(
message => alert(message)
);
};
</script>
Upvotes: 0
Reputation: 11
I didnt find a satisfying answer here, so I'll try to explain what worked for me :
In your elasticemail email API settings, you should make sure you registered and verified the email address / domain name you are trying to use as sender.
By default, the email you used to create your elasticemail account should appear here as "verified" (for me it was gmail and my gmail address). So if you use this same email as sender in the smtpJS config, it should actually work by default I guess.
BUT if you are trying to use a different email then you HAVE to verify it as well as the domain name if it is a specific domain name. It is explained in the elasticemail faq : https://help.elasticemail.com/en/articles/4934400-how-to-verify-your-domain
Hope this helps
Upvotes: 1
Reputation: 11
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.
Upvotes: 1
Reputation: 31
I also encountered the same issue while using it. 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
Upvotes: 3