Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

23
LINES

< > BotCompany Repo | #1026044 // javaMail_sendThroughLocalhost

JavaX fragment (include) [tags: use-pretranspiled]

Uses 715K of libraries. Click here for Pure Java version (2239L/14K).

!include once #1015973 // JavaMail

svoid javaMail_sendThroughLocalhost(S from, S to, S subject, S text) ctex {
  new Properties props;
  props.put("mail.smtp.host", "localhost");
  
  javax.mail.Session session = javax.mail.Session.getInstance(props);

  Message message = new MimeMessage(session);
  message.setFrom(first(InternetAddress.parse(from)));
  message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to));
  message.setSubject(subject);
  message.setText(text);

  print("SENDING MAIL TO: " + to);
  print("From: " + from);
  print("Subject: " + subject);
  printWithIndent("MAIL> ", text);
  
  Transport.send(message);
  
  print("\nMail sent.");
}

Author comment

Began life as a copy of #1003227

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, podlckwnjdmb, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1026044
Snippet name: javaMail_sendThroughLocalhost
Eternal ID of this version: #1026044/9
Text MD5: fe035bf53cd51f75f427c40df498d38a
Transpilation MD5: 0d134b1139970af111eb436b8e19b6e2
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-11-15 22:01:16
Source code size: 699 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 267 / 390
Version history: 8 change(s)
Referenced in: [show references]