contact form email doesn't have the message from a textarea input

my contact form works, but the email i get doesn't have the message from the textarea included. what is the problem here? html
<form onsubmit="emailSend(); reset(); return false;">
<input type="text" id="name" name="name" placeholder="Name" required>
<input type="email" id="email" name="email" placeholder="E-Mail" required>
<textarea rows="5" id="message" cols="60" name="message" placeholder="Message" autocomplete="off" required></textarea>
<button type="submit" class="submit-button">Send message</button>
<form onsubmit="emailSend(); reset(); return false;">
<input type="text" id="name" name="name" placeholder="Name" required>
<input type="email" id="email" name="email" placeholder="E-Mail" required>
<textarea rows="5" id="message" cols="60" name="message" placeholder="Message" autocomplete="off" required></textarea>
<button type="submit" class="submit-button">Send message</button>
js
var userName = document.getElementById('name').value;
var email = document.getElementById('email').value;
var message = document.getElementById('message').value;
var messageBody = "Name " + userName +
"<br/> Email " + email;
"<br/> Message " + message;
var userName = document.getElementById('name').value;
var email = document.getElementById('email').value;
var message = document.getElementById('message').value;
var messageBody = "Name " + userName +
"<br/> Email " + email;
"<br/> Message " + message;
i removed every unnecessary code from above
8 Replies
MarkBoots
MarkBoots12mo ago
what email library/service are you using? where is the emailSend() function coming from?
Crume
CrumeOP12mo ago
it is made with https://smtpjs.com/ and easy smtp access from elasticemail. the function is down below
SmtpJS.com - Send Email from JavaScript
Send email from client-side javascript - free js library
Crume
CrumeOP12mo ago
Email.send({
Host : "smtp.elasticemail.com",
Username : "xxxxxxxxxxxxxxx",
Password : "xxxxxxxxxxx",
To : 'xxxxxxxxx',
From : "xxxxxxxxxxxx",
Subject : "contact request on xxxxxxxxxxxx",
Body : messageBody
}).then(
message => alert(message)
);
Email.send({
Host : "smtp.elasticemail.com",
Username : "xxxxxxxxxxxxxxx",
Password : "xxxxxxxxxxx",
To : 'xxxxxxxxx',
From : "xxxxxxxxxxxx",
Subject : "contact request on xxxxxxxxxxxx",
Body : messageBody
}).then(
message => alert(message)
);
it is filled up with working data, so the contact form itself sends the email out, but doesn't have the message included. the input fields get the value. the textarea not, so i think its different for the textarea, but i don't know why
MarkBoots
MarkBoots12mo ago
can you log the message from the textarea?
Jochem
Jochem12mo ago
there's a semicolon after email I looked at this three times since you posted, and I just spotted it
MarkBoots
MarkBoots12mo ago
good call, i was just making it in codepen (I used the formData constructor to make it easier) https://codepen.io/MarkBoots/pen/zYbzWYW
Jochem
Jochem12mo ago
formData is always an improvement
Crume
CrumeOP12mo ago
Yeah, that was it. Thanks x)
Want results from more Discord servers?
Add your server