Class SendMailHelper

    • Method Detail

      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    String recipient,
                                    String sender)
                             throws javax.mail.MessagingException
        Sends mail without authentication or attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        recipient - The recipient address
        sender - The sender address
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    List<String> recipients,
                                    String sender)
                             throws javax.mail.MessagingException
        Sends mail without authentication or attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        recipients - The recipients addresses
        sender - The sender address
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    String recipient,
                                    String sender,
                                    boolean async)
                             throws javax.mail.MessagingException
        Sends mail without authentication or attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        recipient - The recipient address
        sender - The sender address
        async - True to use asynchronous mail sending
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    List<String> recipients,
                                    String sender,
                                    boolean async)
                             throws javax.mail.MessagingException
        Sends mail without authentication or attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        recipients - The recipients addresses
        sender - The sender address
        async - True to use asynchronous mail sending
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    String recipient,
                                    String sender,
                                    String host,
                                    long port,
                                    String securityProtocol,
                                    boolean async)
                             throws javax.mail.MessagingException
        Sends mail without authentication or attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        recipient - The recipient address
        sender - The sender address
        host - The server mail host
        port - The server mail port
        securityProtocol - The server mail security protocol
        async - True to use asynchronous mail sending
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    List<String> recipients,
                                    String sender,
                                    String host,
                                    long port,
                                    String securityProtocol,
                                    boolean async)
                             throws javax.mail.MessagingException
        Sends mail without authentication or attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        recipients - The recipients addresses
        sender - The sender address
        host - The server mail host
        port - The server mail port
        securityProtocol - The server mail security protocol
        async - True to use asynchronous mail sending
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    String recipient,
                                    String sender,
                                    String host,
                                    long port,
                                    String securityProtocol,
                                    String user,
                                    String password,
                                    boolean async)
                             throws javax.mail.MessagingException
        Sends mail with authentication, without attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        recipient - The recipient address
        sender - The sender address
        host - The server mail host
        port - The server port
        securityProtocol - The server mail security protocol
        user - The user name
        password - The user password
        async - True to use asynchronous mail sending
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    List<String> recipients,
                                    String sender,
                                    String host,
                                    long port,
                                    String securityProtocol,
                                    String user,
                                    String password,
                                    boolean async)
                             throws javax.mail.MessagingException
        Sends mail with authentication, without attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        recipients - The recipients addresses
        sender - The sender address
        host - The server mail host
        port - The server port
        securityProtocol - The server mail security protocol
        user - The user name
        password - The user password
        async - True to use asynchronous mail sending
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    Collection<File> attachments,
                                    String recipient,
                                    String sender)
                             throws javax.mail.MessagingException,
                                    IOException
        Sends mail without authentication, with attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        attachments - the file attachments. Can be null.
        recipient - The recipient address
        sender - The sender address
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
        IOException - if an error occurs while attaching a file.
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    Collection<File> attachments,
                                    List<String> recipients,
                                    String sender)
                             throws javax.mail.MessagingException,
                                    IOException
        Sends mail without authentication, with attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        attachments - the file attachments. Can be null.
        recipients - The recipients addresses
        sender - The sender address
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
        IOException - if an error occurs while attaching a file.
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    Collection<File> attachments,
                                    String recipient,
                                    String sender,
                                    List<String> cc,
                                    List<String> bcc,
                                    boolean async)
                             throws javax.mail.MessagingException,
                                    IOException
        Sends mail without authentication, with attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        attachments - the file attachments. Can be null.
        recipient - The recipient address
        sender - The sender address
        cc - Carbon copy address list. Can be null.
        bcc - Blind carbon copy address list. Can be null.
        async - True to use asynchronous mail sending
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
        IOException - if an error occurs while attaching a file.
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    Collection<File> attachments,
                                    List<String> recipients,
                                    String sender,
                                    List<String> cc,
                                    List<String> bcc,
                                    boolean async)
                             throws javax.mail.MessagingException,
                                    IOException
        Sends mail without authentication, with attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        attachments - the file attachments. Can be null.
        recipients - The recipients addresses
        sender - The sender address
        cc - Carbon copy address list. Can be null.
        bcc - Blind carbon copy address list. Can be null.
        async - True to use asynchronous mail sending
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
        IOException - if an error occurs while attaching a file.
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    Collection<File> attachments,
                                    String recipient,
                                    String sender,
                                    List<String> cc,
                                    List<String> bcc,
                                    boolean deliveryReceipt,
                                    boolean readReceipt,
                                    boolean async)
                             throws javax.mail.MessagingException,
                                    IOException
        Sends mail without authentication, with attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        attachments - the file attachments. Can be null.
        recipient - The recipient address
        sender - The sender address
        cc - Carbon copy address list. Can be null.
        bcc - Blind carbon copy address list. Can be null.
        deliveryReceipt - true to request that the receiving mail server send a notification when the mail is received.
        readReceipt - true to request that the receiving mail client send a notification when the person opens the mail.
        async - True to use asynchronous mail sending
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
        IOException - if an error occurs while attaching a file.
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    Collection<File> attachments,
                                    List<String> recipients,
                                    String sender,
                                    List<String> cc,
                                    List<String> bcc,
                                    boolean deliveryReceipt,
                                    boolean readReceipt,
                                    boolean async)
                             throws javax.mail.MessagingException,
                                    IOException
        Sends mail without authentication, with attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        attachments - the file attachments. Can be null.
        recipients - The recipients addresses
        sender - The sender address
        cc - Carbon copy address list. Can be null.
        bcc - Blind carbon copy address list. Can be null.
        deliveryReceipt - true to request that the receiving mail server send a notification when the mail is received.
        readReceipt - true to request that the receiving mail client send a notification when the person opens the mail.
        async - True to use asynchronous mail sending
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
        IOException - if an error occurs while attaching a file.
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    Collection<File> attachments,
                                    String recipient,
                                    String sender,
                                    List<String> cc,
                                    List<String> bcc,
                                    boolean deliveryReceipt,
                                    boolean readReceipt,
                                    String host,
                                    long port,
                                    String securityProtocol,
                                    boolean async)
                             throws javax.mail.MessagingException,
                                    IOException
        Sends mail without authentication, with attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        attachments - the file attachments. Can be null.
        recipient - The recipient address
        sender - The sender address
        cc - Carbon copy address list. Can be null.
        bcc - Blind carbon copy address list. Can be null.
        deliveryReceipt - true to request that the receiving mail server send a notification when the mail is received.
        readReceipt - true to request that the receiving mail client send a notification when the person opens the mail.
        host - The server mail host
        port - The server port
        securityProtocol - The server mail security protocol
        async - True to use asynchronous mail sending
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
        IOException - if an error occurs while attaching a file.
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    Collection<File> attachments,
                                    List<String> recipients,
                                    String sender,
                                    List<String> cc,
                                    List<String> bcc,
                                    boolean deliveryReceipt,
                                    boolean readReceipt,
                                    String host,
                                    long port,
                                    String securityProtocol,
                                    boolean async)
                             throws javax.mail.MessagingException,
                                    IOException
        Sends mail without authentication, with attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        attachments - the file attachments. Can be null.
        recipients - The recipients addresses
        sender - The sender address
        cc - Carbon copy address list. Can be null.
        bcc - Blind carbon copy address list. Can be null.
        deliveryReceipt - true to request that the receiving mail server send a notification when the mail is received.
        readReceipt - true to request that the receiving mail client send a notification when the person opens the mail.
        host - The server mail host
        port - The server port
        securityProtocol - The server mail security protocol
        async - True to use asynchronous mail sending
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
        IOException - if an error occurs while attaching a file.
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    Collection<File> attachments,
                                    String recipient,
                                    String sender,
                                    List<String> cc,
                                    List<String> bcc,
                                    boolean deliveryReceipt,
                                    boolean readReceipt,
                                    String host,
                                    long port,
                                    String securityProtocol,
                                    String user,
                                    String password,
                                    boolean async)
                             throws javax.mail.MessagingException,
                                    IOException
        Sends mail with authentication and attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        attachments - the file attachments. Can be null.
        recipient - The recipient address
        sender - The sender address. Can be null when called by MailChecker.
        cc - Carbon copy address list. Can be null.
        bcc - Blind carbon copy address list. Can be null.
        deliveryReceipt - true to request that the receiving mail server send a notification when the mail is received.
        readReceipt - true to request that the receiving mail client send a notification when the person opens the mail.
        host - The server mail host. Can be null when called by MailChecker.
        securityProtocol - the security protocol to use when transporting the email
        port - The server port
        user - The user name
        password - The user password
        async - True to use asynchronous mail sending
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
        IOException - if an error occurs while attaching a file.
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    Collection<File> attachments,
                                    List<String> recipients,
                                    String sender,
                                    List<String> cc,
                                    List<String> bcc,
                                    boolean deliveryReceipt,
                                    boolean readReceipt,
                                    String host,
                                    long port,
                                    String securityProtocol,
                                    String user,
                                    String password,
                                    boolean async)
                             throws javax.mail.MessagingException,
                                    IOException
        Sends mail with authentication and attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        attachments - the file attachments. Can be null.
        recipients - The recipients addresses
        sender - The sender address. Can be null when called by MailChecker.
        cc - Carbon copy address list. Can be null.
        bcc - Blind carbon copy address list. Can be null.
        deliveryReceipt - true to request that the receiving mail server send a notification when the mail is received.
        readReceipt - true to request that the receiving mail client send a notification when the person opens the mail.
        host - The server mail host. Can be null when called by MailChecker.
        securityProtocol - the security protocol to use when transporting the email
        port - The server port
        user - The user name
        password - The user password
        async - True to use asynchronous mail sending
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
        IOException - if an error occurs while attaching a file.
      • sendMail

        public static void sendMail​(String subject,
                                    String htmlBody,
                                    String textBody,
                                    Collection<File> attachments,
                                    List<String> recipients,
                                    String sender,
                                    List<String> cc,
                                    List<String> bcc,
                                    boolean deliveryReceipt,
                                    boolean readReceipt,
                                    String host,
                                    long port,
                                    String securityProtocol,
                                    String user,
                                    String password,
                                    boolean async,
                                    boolean singleEmail)
                             throws javax.mail.MessagingException,
                                    IOException
        Sends mail with authentication and attachments.
        Parameters:
        subject - The mail subject
        htmlBody - The HTML mail body. Can be null.
        textBody - The text mail body. Can be null.
        attachments - the file attachments. Can be null.
        recipients - The recipients addresses
        sender - The sender address. Can be null when called by MailChecker.
        cc - Carbon copy address list. Can be null.
        bcc - Blind carbon copy address list. Can be null.
        deliveryReceipt - true to request that the receiving mail server send a notification when the mail is received.
        readReceipt - true to request that the receiving mail client send a notification when the person opens the mail.
        host - The server mail host. Can be null when called by MailChecker.
        securityProtocol - the security protocol to use when transporting the email
        port - The server port
        user - The user name
        password - The user password
        async - True to use asynchronous mail sending
        singleEmail - true if just one email is sent with all recipients. Otherwise, an email will be sent for each recipients.
        Throws:
        javax.mail.MessagingException - If an error occurred while preparing or sending email
        IOException - if an error occurs while attaching a file.
      • inlineCSS

        public static String inlineCSS​(String html)
        This method inline css in <style> tags directly in the appropriates tags. e.g. : <style>h1 {color: red;}</style> <h1>a</h1> becomes <h1 style="color: red">a</h1>
        Parameters:
        html - The initial non null html
        Returns:
        The inlined html