Good Morning,
I hope someone will be of great help :)
I Just want to know how i will write the JavaScript :)
I currently have text field, and a button, but i want the button to send the message box info to an email address onclick, but im not quite sure how to do the JavaScript part, i want to know how i can call my Java Class in the JS and then then do the onclick function to send the Email.
Thanks so much in advance
public class SendMailTLS {
public static void main(String[] args) {
final String username = "diamantengoud@gmail.com";
final String password = "********";
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "587");
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("diamantengoud@gmail.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("jp.pretorius@bmgi.co.za"));
message.setSubject("Testing Subject");
message.setText("Dear Mail Crawler,"
+ "\n\n No spam to my email, please!");
Transport.send(message);
System.out.println("Done");
} catch (MessagingException e) {
throw new RuntimeException(e);
}
}
<form method="post" enctype="text/plain" >
<h1>Send a Message</h1>
<br>
<br>
<form class="form-horizontal" a>
<div class="form-group">
<label for="inputName" class="control-label col-xs-2">Name</label>
<div class="col-xs-10">
<input type="" class="form-control" id="inputName" placeholder="">
</div>
</div>
<div class="form-group">
<label for="inputEmail" class="control-label col-xs-2">Email</label>
<div class="col-xs-10">
<input type="" class="form-control" id="inputEmail" placeholder="">
</div>
</div>
<div class="form-group" >
<label for="inputMessage">Message</label>
<textarea class="form-control" style="height: 300px" id="inputMessage" rows=""></textarea>
</div>
<div class="form-group">
<div class="col-xs-offset-2 col-xs-50">
<button onclick="" value="Send" id="send-button" type="submit" class="btn btn-primary">Send</button>
</div>
</div>
</form>