Advertisement
Guest User

Untitled

a guest
Dec 16th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. import java.util.Properties;
  2.  
  3. import javax.mail.Message;
  4. import javax.mail.MessagingException;
  5. import javax.mail.PasswordAuthentication;
  6. import javax.mail.Session;
  7. import javax.mail.Transport;
  8. import javax.mail.internet.InternetAddress;
  9. import javax.mail.internet.MimeMessage;
  10.  
  11. public class FranklinSender {
  12.  
  13. public static void main(String[] args) {
  14.  
  15. final String username = "franklin@expocsgo.com";
  16. final String password = "piska";
  17.  
  18. Properties props = new Properties();
  19. props.put("mail.smtp.auth", "true");
  20. props.put("mail.smtp.starttls.enable", "true");
  21. props.put("mail.smtp.host", "expocsgo.com");
  22. props.put("mail.smtp.port", "587");
  23. props.put("mail.smtp.starttls.enable", "true");
  24. props.put("mail.smtp.ssl.trust", "*");
  25.  
  26. Session session = Session.getInstance(props,
  27. new javax.mail.Authenticator() {
  28. protected PasswordAuthentication getPasswordAuthentication() {
  29. return new PasswordAuthentication(username, password);
  30. }
  31. });
  32.  
  33. try {
  34. Message message = new MimeMessage(session);
  35. message.setFrom(new InternetAddress("franklin@expocsgo.com"));
  36. message.setRecipients(Message.RecipientType.TO,
  37. InternetAddress.parse("pylypenko.albina@yandex.ru"));
  38. message.setSubject("Я чего то не понял");
  39. message.setText("Что тут происходит?");
  40. message.addHeader("Precedence", "bulk");
  41. message.addHeader("Feedback-ID", "1:1:1:4fFnDehZtWnRPe");
  42.  
  43. Transport.send(message);
  44.  
  45. System.out.println("Done");
  46.  
  47. } catch (MessagingException e) {
  48. throw new RuntimeException(e);
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement