Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.42 KB | None | 0 0
  1.     public void sendVerificationEmail(final RegistrationRequestEntity entity, final String UID, @Nullable final boolean isSpecial) {
  2.         AsyncTask.execute(new Runnable() {
  3.             @Override
  4.             public void run() {
  5.                 final String username = "robot@art-coral.com";
  6.                 final String password = "0Z8c1S3b";
  7.  
  8.                 Properties props = new Properties();
  9.                 props.put("mail.smtp.auth", "true");
  10.                 props.put("mail.smtp.starttls.enable", "false");
  11.                 props.put("mail.smtp.host", "mail.art-coral.com");
  12.                 props.put("mail.smtp.port", "25");
  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.                 try {
  21.                     Message message = new MimeMessage(session);
  22.                     message.setFrom(new InternetAddress("robot@art-coral.com"));
  23.                     message.setRecipients(Message.RecipientType.TO,
  24.                             InternetAddress.parse(entity.getMail()));
  25.                     message.setSubject(getString(R.string.message_email_title));
  26.  
  27.                     message.setText(
  28.                             getString(R.string.message_email_message_1) + "\n\n" +
  29.                             getString(R.string.message_email_message_2) +
  30.                             "\n\n\n" +
  31.                             getString(R.string.message_email_url) +
  32.                             buildEncodedData(entity, UID, isSpecial) +
  33.                             "\n\n\n" +
  34.                             getString(R.string.message_email_message_3) + "\n\n" +
  35.                             getString(R.string.registration_email_hint) + ": " + entity.getMail() + "\n" +
  36.                             getString(R.string.registration_password_hint) + ": " + entity.getPass() +
  37.                             "\n\n\n" +
  38.                             getString(R.string.message_email_message_4)
  39.                     );
  40.  
  41.                     Transport.send(message);
  42.  
  43.                 } catch (MessagingException e) {
  44.                     throw new RuntimeException(e);
  45.                 }
  46.             }
  47.         });
  48.  
  49.         notifyUser();
  50.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement