4

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?

6
  • 1
    You have to use an actual email account to send the email. You should move sending the emajl to the backend though. PHPMailer it's pretty simple to set up. Commented May 2, 2022 at 22:07
  • @ChrisG — smtp.js is a third-party backend and (although obfuscated for the question) it looks like credentials for an actual email account are being provided.. Commented May 2, 2022 at 22:14
  • Isn't the error message just saying that the email address being read from the document.getElementById("email").value isn't allowed to send email from the account you've provided the credentials of? (My SMTP isn't quite good enough for me to be confident enough to claim that as an answer). Commented May 2, 2022 at 22:16
  • 1
    When I send out emails from contact forms, the FROM address usually has to be the one doing the sending. This is done to prevent people from faking the sender. You can however set an arbitrary email as Reply-To, which is where I put the sender's email they enter into the form. In other words, you need From: "[email protected]", and you can try adding ReplyTo: document.getElementById("email").value, Commented May 2, 2022 at 22:35
  • 1
    I put my actual email as Username and From and it worked on the spot. Are you still getting the same error message? Commented May 3, 2022 at 7:40

8 Answers 8

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
1

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.

Comments

1

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

Comments

0

Two changes needed,

  1. You have to use the password of the server you have created. (Not your Elasticemail account password)
  2. Swap 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>

Comments

0

The 2-step verification should be on your gmail account then do email verification in elasticemail website.

Comments

0

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?

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.

Comments

0

Swap to and from line. It will work!

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
-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

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.