我正在尝试使用SmtpJS来捕获表单的值并将其发送到我的电子邮件。
到目前为止,我有以下表单标记:
<form>
<input type="text" name="fullname" placeholder="Full Name" />
<input type="text" name="idea" placeholder="Idea" />
<div class="fruits">
<input type="checkbox" id="apple" name="apple" value="apple">
<label for="apple"> Apple</label><br>
<input type="checkbox" id="orange" name="orange" value="orange">
<label for="orange"> Orange</label><br>
</div>
<div class="gender">
<input type="radio" id="male" name="gender" value="male">
<label for="male">Male</label><br>
<input type="radio" id="female" name="gender" value="female">
<label for="female">Female</label><br>
</div>
<input type="submit" value="submit" onclick={() => sendEmail() }/>
</form>
我了解要使用 smtpjs,您首先需要像这样包含它:
<script src="https://smtpjs.com/v3/smtp.js">
</script>
然后你需要一个函数来实际捕获和发送电子邮件,如下所示:
function sendEmail(){
Email.send({
Host : "smtp.yourisp.com",
Username : "username",
Password : "password",
To : 'them@website.com',
From : "you@isp.com",
Subject : "This is the subject",
Body : "And this is the body"
}).then(
message => alert(message)
);
}
如何捕获输入values、checked复选框和selected单选按钮值并将它们包含在将发送到我的电子邮件的电子邮件正文中?