I've been trying to setup a simple form that will send an email to the user upon submission. I've been working with nodejs and have installed nodemailer to help aid me. I'm using gmail as the SMTP server, and was encountering some issues. Here is the html:
<title> Schedule an Appointment - Name </title> <link rel="stylesheet" type="text/css" href="public/styles.css"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <script src="public/script.js"></script>
<ul id="nav"> <li><a href="page.html"> Home </a><br> <br> <li><a class="active" href=""> Appointment </a> <br> <br> <li><a href="specsPage.html"> Build </a> <br> <br> <li><a href="contactPage.html"> Contact </a> <br> <br> </ul> <div id="schedulePage"> <h4> Schedule an Appointment </h4> <div id="fullForm"> First Name: <input id="firstname" type="text" name="firstname" placeholder="First Name..."> <br> <br> Last Name: <input id="lastname" type="text" name="lastname" placeholder="Last Name..."> <br> <br> Email: <input id="email" type="text" name="email" placeholder="Email..."> <br> <br> Phone Number: <input id="phone" type="text" name="phone" placeholder="Callback Number..."> <br> <br> <input id="send_email" type="submit" name="submit" value="Submit"> <span id="message"></span> </div> </div>
And the scripts:
$(document).ready(function(){ var from,to,subject,text; $("#send_email").click(function(){ to=$("#email").val(); firstname=$("#firstname").val(); lastname=$("#lastname").val(); $("#message").text("Sending E-mail...Please wait"); $.get("http://localhost:4000/send",{to:to,subject:firstname,text:lastname},function(data){ if(data=="sent"){ $("#message").empty().html(" Email is been sent at " + to + " . Please check inbox !"); } }); });