Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SendMailTLS {
- public static void main(String[] args) {
- final String username = "diamantengoud@gmail.com";
- final String password = "9008275195083";
- 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,"
- + "nn 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>
Add Comment
Please, Sign In to add comment