Tabnine Logo
javax.mail
Code IndexAdd Tabnine to your IDE (free)

How to use javax.mail

Best Java code snippets using javax.mail (Showing top 20 results out of 5,121)

origin: spring-projects/spring-framework

/**
 * Return the JavaMail {@code Session},
 * lazily initializing it if hasn't been specified explicitly.
 */
public synchronized Session getSession() {
  if (this.session == null) {
    this.session = Session.getInstance(this.javaMailProperties);
  }
  return this.session;
}
origin: log4j/log4j

 protected PasswordAuthentication getPasswordAuthentication() {
  return new PasswordAuthentication(smtpUsername, smtpPassword);
 }
};
origin: gocd/gocd

public Transport getTransport() throws NoSuchProviderException {
  return session.getTransport();
}
origin: spring-projects/spring-framework

/**
 * Obtain a Transport object from the given JavaMail Session,
 * using the configured protocol.
 * <p>Can be overridden in subclasses, e.g. to return a mock Transport object.
 * @see javax.mail.Session#getTransport(String)
 * @see #getSession()
 * @see #getProtocol()
 */
protected Transport getTransport(Session session) throws NoSuchProviderException {
  String protocol    = getProtocol();
  if (protocol == null) {
    protocol = session.getProperty("mail.transport.protocol");
    if (protocol == null) {
      protocol = DEFAULT_PROTOCOL;
    }
  }
  return session.getTransport(protocol);
}
origin: aws/aws-sdk-java

/**
 * Checks that the message can be sent using AWS Simple E-mail Service.
 */
private void checkMessage(Message msg) throws MessagingException {
  if (msg == null) {
    throw new MessagingException("Message is null");
  }
  if (!(msg instanceof MimeMessage)) {
    throw new MessagingException(
        "AWS Mail Service can only send MimeMessages");
  }
}
origin: spring-projects/spring-framework

/**
 * Validate that this instance can connect to the server that it is configured
 * for. Throws a {@link MessagingException} if the connection attempt failed.
 */
public void testConnection() throws MessagingException {
  Transport transport = null;
  try {
    transport = connectTransport();
  }
  finally {
    if (transport != null) {
      transport.close();
    }
  }
}
origin: oblac/jodd

/**
 * Returns email store.
 *
 * @return {@link com.sun.mail.imap.IMAPStore}
 * @throws NoSuchProviderException if a provider for the given protocol is not found.
 */
protected Store getStore(final Session session) throws NoSuchProviderException {
  return session.getStore(PROTOCOL_IMAP);
}
origin: oblac/jodd

/**
 * Returns {@code true} if message is deleted.
 *
 * @return {@code true} if message is deleted.
 */
public boolean isDeleted() {
  return flags.contains(Flag.DELETED);
}
origin: oblac/jodd

/**
 * Closes folder if opened and expunge deleted messages.
 */
protected void closeFolderIfOpened(final Folder folder) {
  if (folder != null) {
    try {
      folder.close(true);
    } catch (final MessagingException ignore) {
    }
  }
}
origin: aws/aws-sdk-java

public AWSJavaMailTransport(Session session, URLName urlname) {
  super(session, urlname);
  this.accessKey = session.getProperty(AWS_ACCESS_KEY_PROPERTY);
  this.secretKey = session.getProperty(AWS_SECRET_KEY_PROPERTY);
  this.httpsEndpoint = session.getProperty(AWS_EMAIL_SERVICE_ENDPOINT_PROPERTY);
}
origin: oblac/jodd

/**
 * Creates a new {@link OutputStreamTransport}.
 *
 * @param session {@link Session}.
 */
public OutputStreamTransport(final Session session) {
  super(session, new URLName("JODD_MAIL_2_EML", null, -1, null, null, null));
}
origin: oblac/jodd

/**
 * Marks messages as seen after receiving them.
 */
public ReceiverBuilder markSeen() {
  this.flagsToSet.add(Flags.Flag.SEEN);
  return this;
}
origin: oblac/jodd

/**
 * Returns {@code true} if mail session is still connected.
 *
 * @return {@code true} if mail session is still connected.
 */
public boolean isConnected() {
  return service.isConnected();
}
origin: gocd/gocd

  protected PasswordAuthentication getPasswordAuthentication() {
    return new PasswordAuthentication(username, password);
  }
}
origin: spring-projects/spring-framework

@Override
public synchronized void close() throws MessagingException {
  if ("".equals(connectedHost)) {
    throw new MessagingException("close failure");
  }
  this.closeCalled = true;
}
origin: oblac/jodd

/**
 * Returns {@code true} if message is seen.
 *
 * @return {@code true} if message is seen.
 */
public boolean isSeen() {
  return flags.contains(Flag.SEEN);
}
origin: spring-projects/spring-framework

  @Override
  protected Transport getTransport(Session sess) throws NoSuchProviderException {
    assertEquals("bogusValue", sess.getProperty("bogusKey"));
    return super.getTransport(sess);
  }
};
origin: spring-projects/spring-framework

@Override
public void connect(String host, int port, String username, String password) throws MessagingException {
  if (host == null) {
    throw new MessagingException("no host");
  }
  this.connectedHost = host;
  this.connectedPort = port;
  this.connectedUsername = username;
  this.connectedPassword = password;
  setConnected(true);
}
origin: oblac/jodd

/**
 * Returns {@code true} if message is answered.
 *
 * @return {@code true} if message is answered.
 */
public boolean isAnswered() {
  return flags.contains(Flag.ANSWERED);
}
origin: oblac/jodd

/**
 * Returns {@code true} is message is flagged.
 *
 * @return {@code true} is message is flagged.
 */
public boolean isFlagged() {
  return flags.contains(Flag.FLAGGED);
}
javax.mail

Most used classes

  • MimeMessage
    This class represents a MIME style email message. It implements the Message abstract class and the
  • InternetAddress
    This class represents an Internet email address using the syntax of RFC822 [http://www.ietf.org/rfc/
  • Session
    The Session class represents a mail session and is not subclassed. It collects together properties a
  • Transport
    Abstract class modeling a message transport.
  • MimeMultipart
    The MimeMultipart class is an implementation of the abstract Multipart class that uses MIME conventi
  • PasswordAuthentication,
  • MessagingException,
  • Message,
  • Multipart,
  • BodyPart,
  • MimeUtility,
  • ByteArrayDataSource,
  • Folder,
  • Store,
  • Address,
  • Header,
  • Flags,
  • ContentType,
  • Part
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now