i can produce an email with javascript and smtp.js.
I would however like to add fieldvalues from the form into the body and cannot find the right syntax.
there is an inputfield for email and a field for a number, i tried : var email=Form.email.value; var body = " Well that was easy!! "+email;
Subject: "Sending Email using javascript", Body: "here i would like to add fieldvalues", })
Can anyone please give a hint, i do not use javascript very often. Seems i will have to start learning. . .
Regards, Jan
Here is the code i used:
<!DOCTYPE html>
<html>
<head>
<title>Send Mail</title>
<script src=
"https://smtpjs.com/v3/smtp.js">
</script>
<script type="text/javascript">
function sendEmail() {
Email.send({
Host: "smtp.gmail.com",
Username: "sender@email_address.com",
Password: "Enter your password",
To: 'receiver@email_address.com',
From: "sender@email_address.com",
Subject: "Sending Email using javascript",
Body: "Well that was easy!!",
})
.then(function (message) {
alert("mail sent successfully")
});
}
</script>
</head>
<body>
<form method="post">
<!-- here i would like to enter an e-mail-address that i want to use in the e-mail that is sent -->
E-Mail: <input class="input2" type="text" name="email"><br>
<input type="button" value="Send Email"
onclick="sendEmail()" />
</form>
</body>
</html>
I mixed up var and let.
so far it is sending an email and i can enter some text from the inputfield with:
let email = document.getElementById("email").value;
Now i need to get an array in property "To" so i can sand to 2 email-addresses.
regards,
Jan