Advertisement
Guest User

Untitled

a guest
Jun 26th, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. import java.util.Properties;
  2. import javax.mail.Message;
  3. import javax.mail.MessagingException;
  4. import javax.mail.PasswordAuthentication;
  5. import javax.mail.Session;
  6. import javax.mail.Transport;
  7. import javax.mail.internet.InternetAddress;
  8. import javax.mail.internet.MimeMessage;
  9.  
  10.  
  11. public class Main {
  12.  
  13. public static void main(String[] args)
  14. // TODO Auto-generated method stub
  15. {
  16. Properties props = new Properties();
  17. props.put("mail.smtp.host", "smtp.gmail.com");
  18. props.put("mail.smtp.socketFactory.port", "465");
  19. props.put("mail.smtp.socketFactory.class",
  20. "javax.net.ssl.SSLSocketFactory");
  21. props.put("mail.smtp.auth", "true");
  22. props.put("mail.smtp.port", "465");
  23.  
  24. Session session = Session.getDefaultInstance(props,
  25. new javax.mail.Authenticator() {
  26. protected PasswordAuthentication getPasswordAuthentication() {
  27. return new PasswordAuthentication("zhouws95@gmail.com","@02021995");
  28. }
  29. });
  30.  
  31. try {
  32.  
  33. Message message = new MimeMessage(session);
  34. message.setFrom(new InternetAddress("zhouws95@gmail.com"));
  35. message.setRecipients(Message.RecipientType.TO,
  36. InternetAddress.parse("sujamh0524@gmail.com"));
  37. message.setSubject("Bakla ka");
  38. message.setText("Dear Mail Crawler," +
  39. "\n\n No spam to my email, please!");
  40.  
  41. Transport.send(message);
  42.  
  43. System.out.println("Done");
  44.  
  45. } catch (MessagingException e) {
  46. throw new RuntimeException(e);
  47. }
  48. }
  49.  
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement