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

40
LINES

< > BotCompany Repo | #1003227 // JavaMail Test (send through gmail)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 639K of libraries. Click here for Pure Java version (2351L/15K).

!7

lib 1400085 // JavaMail

sS recipient = "info@botcompany.de";
  //"stefan.reich.maker.of.eye@gmail.com";

import javax.mail.*;
import javax.mail.PasswordAuthentication;
import javax.mail.internet.*;

p {
  final S username = "stefan.reich.maker.of.eye@gmail.com";
  final S password = loadSecretTextFileMandatory("gmail-pw").trim();

  new Properties props;
  props.put("mail.smtp.auth", "true");
  props.put("mail.smtp.starttls.enable", "true");
  props.put("mail.smtp.host", "smtp.gmail.com");
  props.put("mail.smtp.port", "587");

  Session session = Session.getInstance(props,
    new javax.mail.Authenticator() {
    protected PasswordAuthentication getPasswordAuthentication() {
      return new PasswordAuthentication(username, password);
    }
  });

  Message message = new MimeMessage(session);
  message.setFrom(new InternetAddress(username));
  message.setRecipients(Message.RecipientType.TO,
    InternetAddress.parse(recipient));
  message.setSubject("Testing Subject");
  message.setText("Dear Mail Crawler,"
    + "\n\n No spam to my email, please!");

  Transport.send(message);

  print("Done");
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, nbgitpuheiab, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1003227
Snippet name: JavaMail Test (send through gmail)
Eternal ID of this version: #1003227/4
Text MD5: 3d1517df524a527303f74b450ed24613
Transpilation MD5: c59bb443b1392618309445c11d47d8d1
Author: stefan
Category: javax
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-11-15 17:26:08
Source code size: 1159 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 572 / 1174
Version history: 3 change(s)
Referenced in: [show references]