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

23
LINES

< > BotCompany Repo | #1003303 // gmailSendSession - open SMTP session for sending mail

JavaX fragment (include)

// requires !1003225 (JavaMail)

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

static Session gmailSendSession(fS user, S pass) {
  if (pass == null) pass = findGMailPassword(user);
  final S _pass = pass;

	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");

	ret Session.getInstance(props,
	  new javax.mail.Authenticator() {
		protected PasswordAuthentication getPasswordAuthentication() {
			return new PasswordAuthentication(user, _pass);
		}
	});
}

Author comment

Began life as a copy of #1003227

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1003303
Snippet name: gmailSendSession - open SMTP session for sending mail
Eternal ID of this version: #1003303/1
Text MD5: 8503f13d93a34f4d7685cc7f30784315
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-07-29 16:02:41
Source code size: 667 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 610 / 611
Referenced in: #1003307 - newGMail
#1006654 - Standard functions list 2 (LIVE, continuation of #761)