response = BASE64EncoderStream.encode(response); transport.issueCommand("AUTH XOAUTH2 " + new String(response), 235);
/** * Issue the <code>HELO</code> command. * * @param domain our domain * @exception MessagingException for failures * @since JavaMail 1.4.1 */ protected void helo(String domain) throws MessagingException { if (domain != null) issueCommand("HELO " + domain, 250); else issueCommand("HELO", 250); }
/** * Issue the <code>HELO</code> command. * * @param domain our domain * @exception MessagingException for failures * @since JavaMail 1.4.1 */ protected void helo(String domain) throws MessagingException { if (domain != null) issueCommand("HELO " + domain, 250); else issueCommand("HELO", 250); }
issueCommand("RSET", -1);
issueCommand("RSET", -1);
/** * Issue the <code>STARTTLS</code> command and switch the socket to * TLS mode if it succeeds. * * @exception MessagingException for failures * @since JavaMail 1.4.1 */ protected void startTLS() throws MessagingException { issueCommand("STARTTLS", 220); // it worked, now switch the socket into TLS mode try { serverSocket = SocketFetcher.startTLS(serverSocket, host, session.getProperties(), "mail." + name); initStreams(); } catch (IOException ioex) { closeConnection(); throw new MessagingException("Could not convert socket to TLS", ioex); } }
/** * Issue the <code>STARTTLS</code> command and switch the socket to * TLS mode if it succeeds. * * @exception MessagingException for failures * @since JavaMail 1.4.1 */ protected void startTLS() throws MessagingException { issueCommand("STARTTLS", 220); // it worked, now switch the socket into TLS mode try { serverSocket = SocketFetcher.startTLS(serverSocket, host, session.getProperties(), "mail." + name); initStreams(); } catch (IOException ioex) { closeConnection(); throw new MessagingException("Could not convert socket to TLS", ioex); } }
issueCommand("RSET", -1); try { if (serverSocket != null) issueCommand("RSET", -1); } catch (MessagingException ex) {
issueCommand("RSET", -1); try { if (serverSocket != null) issueCommand("RSET", -1); } catch (MessagingException ex) {
/** * Issue the <code>HELO</code> command. * * @param domain our domain * @exception MessagingException for failures * @since JavaMail 1.4.1 */ protected void helo(String domain) throws MessagingException { if (domain != null) issueCommand("HELO " + domain, 250); else issueCommand("HELO", 250); }
/** * Issue the <code>HELO</code> command. * * @param domain our domain * @exception MessagingException for failures * @since JavaMail 1.4.1 */ protected void helo(String domain) throws MessagingException { if (domain != null) issueCommand("HELO " + domain, 250); else issueCommand("HELO", 250); }
/** * Issue the <code>HELO</code> command. * * @param domain our domain * @exception MessagingException for failures * @since JavaMail 1.4.1 */ protected void helo(String domain) throws MessagingException { if (domain != null) issueCommand("HELO " + domain, 250); else issueCommand("HELO", 250); }
/** * Issue the <code>HELO</code> command. * * @param domain our domain * @exception MessagingException for failures * @since JavaMail 1.4.1 */ protected void helo(String domain) throws MessagingException { if (domain != null) issueCommand("HELO " + domain, 250); else issueCommand("HELO", 250); }
/** * Issue the <code>HELO</code> command. * * @param domain our domain * * @since JavaMail 1.4.1 */ protected void helo(String domain) throws MessagingException { if (domain != null) issueCommand("HELO " + domain, 250); else issueCommand("HELO", 250); }
/** * Issue the <code>HELO</code> command. * * @param domain our domain * * @since JavaMail 1.4.1 */ protected void helo(String domain) throws MessagingException { if (domain != null) issueCommand("HELO " + domain, 250); else issueCommand("HELO", 250); }
/** * Issue the <code>HELO</code> command. * * @param domain our domain * @exception MessagingException for failures * @since JavaMail 1.4.1 */ protected void helo(String domain) throws MessagingException { if (domain != null) issueCommand("HELO " + domain, 250); else issueCommand("HELO", 250); }
Properties props = new Properties(); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.starttls.required", "true"); props.put("mail.smtp.sasl.enable", "false"); session = Session.getInstance(props); session.setDebug(debug); final URLName unusedUrlName = null; SMTPTransport transport = new SMTPTransport(session, unusedUrlName); // If the password is non-null, SMTP tries to do AUTH LOGIN. final String emptyPassword = null; transport.connect(host, port, userEmail, emptyPassword); byte[] response = String.format("user=%s\1auth=Bearer %s\1\1", userEmail, token).getBytes(); response = BASE64EncoderStream.encode(response); transport.issueCommand("AUTH XOAUTH2 " + new String(response), 235); return transport;
private SMTPTransport connectToSmtp(String host, int port, String userEmail, String oauthToken, boolean debug) throws Exception { Properties props = new Properties(); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.starttls.required", "true"); props.put("mail.smtp.sasl.enable", "true"); props.put("mail.smtp.sasl.mechanisms", "XOAUTH2"); props.put("mail.imaps.sasl.mechanisms.oauth2.oauthToken", oauthToken); smtpSession = Session.getInstance(props); smtpSession.setDebug(debug); final URLName unusedUrlName = null; SMTPTransport transport = new SMTPTransport(smtpSession, unusedUrlName); // If the password is non-null, SMTP tries to do AUTH LOGIN. final String emptyPassword = null; transport.connect(host, port, userEmail, emptyPassword); byte[] responseTemp = String.format("user=%s\1auth=Bearer %s\1\1", userEmail, oauthToken).getBytes(); byte[] response = BASE64EncoderStream.encode(responseTemp); transport.issueCommand("AUTH XOAUTH2 " + new String(response), 235); return transport; }
/** * Issue the <code>STARTTLS</code> command and switch the socket to * TLS mode if it succeeds. * * @exception MessagingException for failures * @since JavaMail 1.4.1 */ protected void startTLS() throws MessagingException { issueCommand("STARTTLS", 220); // it worked, now switch the socket into TLS mode try { serverSocket = SocketFetcher.startTLS(serverSocket, host, session.getProperties(), "mail." + name); initStreams(); } catch (IOException ioex) { closeConnection(); throw new MessagingException("Could not convert socket to TLS", ioex); } }
/** * Issue the <code>STARTTLS</code> command and switch the socket to * TLS mode if it succeeds. * * @exception MessagingException for failures * @since JavaMail 1.4.1 */ protected void startTLS() throws MessagingException { issueCommand("STARTTLS", 220); // it worked, now switch the socket into TLS mode try { serverSocket = SocketFetcher.startTLS(serverSocket, host, session.getProperties(), "mail." + name); initStreams(); } catch (IOException ioex) { closeConnection(); throw new MessagingException("Could not convert socket to TLS", ioex); } }