Guest User

Untitled

a guest
Feb 22nd, 2018
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. public class SendMailTLS {
  2.  
  3. public static void main(String[] args) {
  4.  
  5. final String username = "diamantengoud@gmail.com";
  6. final String password = "9008275195083";
  7.  
  8. Properties props = new Properties();
  9. props.put("mail.smtp.auth", "true");
  10. props.put("mail.smtp.starttls.enable", "true");
  11. props.put("mail.smtp.host", "smtp.gmail.com");
  12. props.put("mail.smtp.port", "587");
  13.  
  14. Session session = Session.getInstance(props,
  15. new javax.mail.Authenticator() {
  16. protected PasswordAuthentication getPasswordAuthentication() {
  17. return new PasswordAuthentication(username, password);
  18. }
  19. });
  20.  
  21. try {
  22.  
  23. Message message = new MimeMessage(session);
  24. message.setFrom(new InternetAddress("diamantengoud@gmail.com"));
  25. message.setRecipients(Message.RecipientType.TO,
  26. InternetAddress.parse("jp.pretorius@bmgi.co.za"));
  27. message.setSubject("Testing Subject");
  28. message.setText("Dear Mail Crawler,"
  29. + "nn No spam to my email, please!");
  30.  
  31. Transport.send(message);
  32.  
  33. System.out.println("Done");
  34.  
  35. } catch (MessagingException e) {
  36. throw new RuntimeException(e);
  37. }
  38. }
  39.  
  40.  
  41. <form method="post" enctype="text/plain" >
  42. <h1>Send a Message</h1>
  43. <br>
  44. <br>
  45. <form class="form-horizontal" a>
  46. <div class="form-group">
  47. <label for="inputName" class="control-label col-xs-2">Name</label>
  48. <div class="col-xs-10">
  49. <input type="" class="form-control" id="inputName" placeholder="">
  50. </div>
  51. </div>
  52. <div class="form-group">
  53. <label for="inputEmail" class="control-label col-xs-2">Email</label>
  54. <div class="col-xs-10">
  55. <input type="" class="form-control" id="inputEmail" placeholder="">
  56. </div>
  57. </div>
  58. <div class="form-group" >
  59. <label for="inputMessage">Message</label>
  60. <textarea class="form-control" style="height: 300px" id="inputMessage" rows=""></textarea>
  61. </div>
  62. <div class="form-group">
  63. <div class="col-xs-offset-2 col-xs-50">
  64. <button onclick="" value="Send" id="send-button" type="submit" class="btn btn-primary">Send</button>
  65. </div>
  66. </div>
  67. </form>
Add Comment
Please, Sign In to add comment