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).

1  
!include once #1015973 // JavaMail
2  
3  
svoid javaMail_sendThroughLocalhost(S from, S to, S subject, S text) ctex {
4  
  new Properties props;
5  
  props.put("mail.smtp.host", "localhost");
6  
  
7  
  javax.mail.Session session = javax.mail.Session.getInstance(props);
8  
9  
  Message message = new MimeMessage(session);
10  
  message.setFrom(first(InternetAddress.parse(from)));
11  
  message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to));
12  
  message.setSubject(subject);
13  
  message.setText(text);
14  
15  
  print("SENDING MAIL TO: " + to);
16  
  print("From: " + from);
17  
  print("Subject: " + subject);
18  
  printWithIndent("MAIL> ", text);
19  
  
20  
  Transport.send(message);
21  
  
22  
  print("\nMail sent.");
23  
}

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: 164 / 272
Version history: 8 change(s)
Referenced in: [show references]