Class MailConnection

java.lang.Object
com.netlang.mail.NBaseMailer
com.netlang.mail.MailConnection

public class MailConnection extends NBaseMailer
  • Field Details

    • PROVIDER_MICROSOFT_OFFICE_365

      public static final String PROVIDER_MICROSOFT_OFFICE_365
      See Also:
    • SMTP_PROVIDER

      public static int SMTP_PROVIDER
      The type SMTP
    • GMAIL_PROVIDER

      public static int GMAIL_PROVIDER
      The type GMAIL
    • YAHOO_PROVIDER

      public static int YAHOO_PROVIDER
      The type YAHOO
    • MS360_PROVIDER

      public static int MS360_PROVIDER
  • Constructor Details

    • MailConnection

      public MailConnection(String resourceid) throws com.net4z.APIException
      Throws:
      com.net4z.APIException
    • MailConnection

      public MailConnection() throws Exception
      Throws:
      Exception
    • MailConnection

      public MailConnection(com.netlang.resourceconfig.ResourceConfig rc) throws com.net4z.APIException
      Throws:
      com.net4z.APIException
    • MailConnection

      public MailConnection(com.netlang.session.NetlangSession session, String resourceid) throws com.net4z.APIException
      Throws:
      com.net4z.APIException
  • Method Details

    • main

      public static void main(String[] args) throws Exception
      Throws:
      Exception
    • close

      public void close()
      Close mailbox
    • getInbox

      public MailFolder getInbox() throws Exception
      Throws:
      Exception
    • getFolderNames

      public String[] getFolderNames() throws Exception
      Throws:
      Exception
    • getFolder

      public MailFolder getFolder(String folder) throws Exception
      Throws:
      Exception
    • getFolder

      public MailFolder getFolder(String folder, boolean createIfNotExists) throws Exception
      Throws:
      Exception
    • sendMail

      public void sendMail(String sender, String fromName, String replyTo, String mailTo, String mailCc, String mailBcc, String subject, String message, String contentType) throws Exception
      Throws:
      Exception
    • sendMail

      public void sendMail(String mailTo, String subject, String message) throws Exception
      Throws:
      Exception
    • sendMail

      public void sendMail(String sender, String fromName, String replyTo, String mailTo, String mailCc, String mailBcc, String subject, String message, String contentType, List<NetlangFile> attachments, List<File> attachmentsLocal) throws Exception
      Throws:
      Exception
    • sendGMail

      public void sendGMail(String sender, String mailTo, String cc, String bcc, String subject, String message, String attachements, String contentType) throws Exception
      Send mail via GMAIL
      Parameters:
      sender -
      mailTo -
      cc -
      bcc -
      subject -
      message -
      attachements -
      user -
      password -
      contentType -
      Throws:
      Exception
    • sendGMail

      public void sendGMail(String sender, String mailTo, String cc, String bcc, String subject, String message, String attachements, String contentType, String fromName, String replyTo) throws Exception
      Send mail via GMAIL
      Parameters:
      sender -
      mailTo -
      cc -
      bcc -
      subject -
      message -
      attachements -
      user -
      password -
      contentType -
      Throws:
      Exception
    • sendLive

      public void sendLive(String sender, String mailTo, String cc, String bcc, String subject, String message, String attachements, String contentType) throws Exception
      Send mail via Microsoft Live
      Parameters:
      sender -
      mailTo -
      cc -
      bcc -
      subject -
      message -
      attachements -
      user -
      password -
      contentType -
      Throws:
      Exception
    • sendOutlook

      public void sendOutlook(String sender, String mailTo, String cc, String bcc, String subject, String message, String attachements, String contentType) throws Exception
      Throws:
      Exception
    • sendLive

      public void sendLive(String sender, String mailTo, String cc, String bcc, String subject, String message, String attachements, String user, String password, String contentType, String fromName, String replyTo) throws Exception
      Send mail via Microsoft Live
      Parameters:
      sender -
      mailTo -
      cc -
      bcc -
      subject -
      message -
      attachements -
      user -
      password -
      contentType -
      Throws:
      Exception
    • sendSMTP

      public void sendSMTP(int type, String mailserver, int port, String protocol, String sender, String mailTo, String cc, String bcc, String subject, String message, String attachements, boolean authenticationRequired, boolean useSSL, boolean useTLS, String user, String password, String contentType) throws Exception
      Send mail via SMTP
      Parameters:
      type -
      mailserver -
      port -
      protocol -
      sender -
      mailTo -
      cc -
      bcc -
      subject -
      message -
      attachements -
      authenticationRequired -
      useSSL -
      useTLS -
      user -
      password -
      contentType -
      Throws:
      Exception
    • sendSMTP2

      public void sendSMTP2(String sender, String mailTo, String cc, String bcc, String subject, String message, String attachements, String user, String password, String contentType, String fromName, String replyTo, String protocol, String mailserver, int port, boolean useSSL, boolean useTLS) throws Exception
      Connects to the specified SMTP server and sends an email.
      Parameters:
      sender - the senders name
      mailTo - the receiver(s)
      cc - the cc receiver
      bcc - the bcc receiver
      subject - the subject
      message - the message body (plain or html depending on the content type)
      attachements - the path to the attachemnts
      user - the user for authentication (optional)
      password - the password (optional)
      contentType - the content type, text/plain or text/html
      protocol - SMTPS or SMTP
      mailserver - the address to the mail server
      port - the mailserver's port
      useSSL - if SSL should be used
      useTLS - if TLS should be used.
      Throws:
      Exception
    • sendSMTP

      public void sendSMTP(String sender, String mailTo, String cc, String bcc, String subject, String message, String attachements, String contentType) throws Exception
      Throws:
      Exception
    • sendSMTP

      public void sendSMTP(String sender, String mailTo, String cc, String bcc, String subject, String message, String attachements, String user, String password, String contentType, String protocol, String mailserver, int port, boolean useSSL, boolean useTLS) throws Exception
      Connects to the specified SMTP server and sends an email.
      Parameters:
      sender - the senders name
      mailTo - the receiver(s)
      cc - the cc receiver
      bcc - the bcc receiver
      subject - the subject
      message - the message body (plain or html depending on the content type)
      attachements - the path to the attachemnts
      user - the user for authentication (optional)
      password - the password (optional)
      contentType - the content type, text/plain or text/html
      protocol - SMTPS or SMTP
      mailserver - the address to the mail server
      port - the mailserver's port
      useSSL - if SSL should be used
      useTLS - if TLS should be used.
      Throws:
      Exception
    • sendSMTP

      public void sendSMTP(int type, String mailserver, int port, String protocol, String sender, String mailTo, String cc, String bcc, String subject, String message, String attachements, boolean authenticationRequired, boolean useSSL, boolean useTLS, String user, String password, String contentType, List<byte[]> attachment, List<String> attachmentNames) throws Exception
      Send mail via SMTP
      Parameters:
      type -
      mailserver -
      port -
      protocol -
      sender -
      mailTo -
      cc -
      bcc -
      subject -
      message -
      attachements -
      authenticationRequired -
      useSSL -
      useTLS -
      user -
      password -
      contentType -
      Throws:
      Exception
    • sendYahoo

      public void sendYahoo(String sender, String mailTo, String cc, String bcc, String subject, String message, String attachements, String user, String password, String contentType) throws Exception
      Send mail via YAHOO
      Parameters:
      sender -
      mailTo -
      cc -
      bcc -
      subject -
      message -
      attachements -
      user -
      password -
      contentType -
      Throws:
      Exception
    • sendYahoo

      public void sendYahoo(String sender, String mailTo, String cc, String bcc, String subject, String message, String attachements, String user, String password, String contentType, String fromName, String replyTo) throws Exception
      Send mail via YAHOO
      Parameters:
      sender -
      mailTo -
      cc -
      bcc -
      subject -
      message -
      attachements -
      user -
      password -
      contentType -
      Throws:
      Exception
    • sendMicrosoft365

      public void sendMicrosoft365(String sender, String mailTo, String cc, String bcc, String subject, String message, String attachements, String user, String password, String contentType, String fromName, String replyTo) throws Exception
      Send mail via Microsoft Office 365 with SMTP AUTH Note that this is SMTP AUTH which is different from basic authentication. SMTP AUTH will NOT be deprecated after oct 1 2022. Also note that SMTP AUTH must be enabled per users mailbox or on the tenant in Office 365 admin portal.
      Parameters:
      sender -
      mailTo -
      cc -
      bcc -
      subject -
      message -
      attachements -
      user -
      password -
      contentType -
      fromName -
      replyTo -
      Throws:
      Exception
    • getProvider

      public String getProvider()