Class EmailToolkit

    • Field Detail

      • CONNECTION_TIMEOUT

        public static final String CONNECTION_TIMEOUT
        Deprecated.
        The attribute key for the socket connection timeout in milliseconds.
        See Also:
        Constant Field Values
      • TIMEOUT

        public static final String TIMEOUT
        Deprecated.
        The attribute key for the socket read timeout in milliseconds.
        See Also:
        Constant Field Values
      • WRITE_TIMEOUT

        public static final String WRITE_TIMEOUT
        Deprecated.
        The attribute key for the socket write timeout in milliseconds.
        See Also:
        Constant Field Values
      • SOCKET_FACTORY

        public static final String SOCKET_FACTORY
        Deprecated.
        The attribute key for the socket factory class.
        See Also:
        Constant Field Values
    • Constructor Detail

      • EmailToolkit

        public EmailToolkit()
        Deprecated.
    • Method Detail

      • sendMail

        public static SerialisedEmail sendMail​(String from,
                                               String[] to,
                                               String[] cc,
                                               String[] bcc,
                                               String subject,
                                               String body,
                                               List<SerialisableAttachment> attachments,
                                               String hostname)
        Deprecated.
        This method allows the usage of a host differing from the default host.
        Parameters:
        from - The e-mail-address of the sender of the message. If NULL is provided a system default sender will be used.
        to - The list of addresses the e-mail should be sent to. At least one recipient has to be provided.
        cc - The list of addresses the e-mail should be sent to as 'CC'. NULL is interpreted as no further recipients.
        bcc - The list of addresses the e-mail should be sent to as 'BCC'. NULL is interpreted as no further recipients.
        subject - The subject of the e-mail.
        body - The body text of the e-mail.
        attachments - The attachments for the e-mail. null will be accepted as no attachments.
        hostname - The hostname of the mail system the e-mail should be sent via. If null is provided a system default host will be used.
        Returns:
        The sent email message for further usage.
        Throws:
        InternalServiceException - If an error occurs during creating, sending or serialising the e-mail, an InternalServiceException will be thrown
      • sendMail

        public static SerialisedEmail sendMail​(String from,
                                               String[] to,
                                               String[] cc,
                                               String[] bcc,
                                               String subject,
                                               String body,
                                               List<SerialisableAttachment> attachments,
                                               String hostname,
                                               int hostport,
                                               boolean useTLS,
                                               boolean useSSL,
                                               boolean overtrustful)
        Deprecated.
        This method allows the usage of a host differing from the default host.
        Parameters:
        from - The e-mail-address of the sender of the message. If NULL is provided a system default sender will be used.
        to - The list of addresses the e-mail should be sent to. At least one recipient has to be provided.
        cc - The list of addresses the e-mail should be sent to as 'CC'. NULL is interpreted as no further recipients.
        bcc - The list of addresses the e-mail should be sent to as 'BCC'. NULL is interpreted as no further recipients.
        subject - The subject of the e-mail.
        body - The body text of the e-mail.
        attachments - The attachments for the e-mail. NULL will be accepted as no attachments.
        hostname - The hostname of the mail system the e-mail should be sent via. If NULL is provided a system default host will be used.
        hostport - The smtp port of the mail system the e-mail should be sent via. If 0 is provided the default port 25 will be used.
        useTLS - Whether TLS should be used.
        useSSL - Whether SSL encryption should be used.
        overtrustful - Whether every certificate will be trusted.
        Returns:
        The sent email message for further usage.
        Throws:
        InternalServiceException - If an error occurs during creating, sending or serialising the e-mail, an InternalServiceException will be thrown
      • sendMail

        public static SerialisedEmail sendMail​(String from,
                                               String[] to,
                                               String[] cc,
                                               String[] bcc,
                                               String subject,
                                               String body,
                                               List<SerialisableAttachment> attachments,
                                               String hostname,
                                               int hostport,
                                               String username,
                                               String password,
                                               boolean useTLS,
                                               boolean useSSL,
                                               boolean overtrustful)
        Deprecated.
        This method allows the usage of a host differing from the default host that also needs a username and a password.
        Parameters:
        from - The e-mail-address of the sender of the message. If NULL is provided a system default sender will be used.
        to - The list of addresses the e-mail should be sent to. At least one recipient has to be provided.
        cc - The list of addresses the e-mail should be sent to as 'CC'. NULL is interpreted as no further recipients.
        bcc - The list of addresses the e-mail should be sent to as 'BCC'. NULL is interpreted as no further recipients.
        subject - The subject of the e-mail.
        body - The body text of the e-mail.
        attachments - The attachments for the e-mail. NULL will be accepted as no attachments.
        hostname - The hostname of the mail system the e-mail should be sent via. If NULL is provided a system default host will be used.
        hostport - The smtp port of the mail system the e-mail should be sent via. If 0 is provided the default port 25 will be used.
        username - The username that is needed to authenticate on the smtp-server. NULL means, that no authentication is needed.
        password - The password that is needed to authenticate on the smtp-server. NULL means, that no authentication is needed.
        useTLS - Whether TLS should be used.
        useSSL - Whether SSL encryption should be used.
        overtrustful - Whether every certificate will be trusted.
        Returns:
        The sent email message for further usage.
        Throws:
        InternalServiceException - If an error occurs during creating, sending or serialising the e-mail, an InternalServiceException will be thrown
      • sendMail

        public static SerialisedEmail sendMail​(String from,
                                               String[] to,
                                               String[] cc,
                                               String[] bcc,
                                               String subject,
                                               String body,
                                               List<SerialisableAttachment> attachments,
                                               String hostname,
                                               int hostport,
                                               String username,
                                               String password,
                                               boolean useTLS,
                                               boolean useSSL,
                                               boolean overtrustful,
                                               Map<String,​String> addAttributes)
        Deprecated.
        This method allows the usage of a host differing from the default host that also needs a username and a password.
        The additional attributes could be used e.g. to embed images in a html message.

        NOTE: This method actually sends the e-mail.

        Parameters:
        from - The e-mail-address of the sender of the message. If NULL is provided a system default sender will be used.
        to - The list of addresses the e-mail should be sent to. At least one recipient has to be provided.
        cc - The list of addresses the e-mail should be sent to as 'CC'. NULL is interpreted as no further recipients.
        bcc - The list of addresses the e-mail should be sent to as 'BCC'. NULL is interpreted as no further recipients.
        subject - The subject of the e-mail.
        body - The body text of the e-mail.
        attachments - The attachments for the e-mail. NULL will be accepted as no attachments.
        hostname - The hostname of the mail system the e-mail should be sent via. If NULL is provided a system default host will be used.
        hostport - The smtp port of the mail system the e-mail should be sent via. If 0 is provided the default port 25 will be used.
        username - The username that is needed to authenticate on the smtp-server. NULL means, that no authentication is needed.
        password - The password that is needed to authenticate on the smtp-server. NULL means, that no authentication is needed.
        useTLS - Whether TLS should be used.
        useSSL - Whether SSL encryption should be used.
        overtrustful - Whether every certificate will be trusted.
        addAttributes - A map of additional attributes that could be used for the e-mail.
        Returns:
        The sent email message for further usage.
        Throws:
        InternalServiceException - If an error occurs during creating, sending or serialising the e-mail, an InternalServiceException will be thrown
      • checkException

        public static boolean checkException​(Throwable t)
        Deprecated.
        If the given Throwable or one of its causes is either a ConnectException or an UnknownHostException, this method will return true, to indicate, that there may be a temporary problem with sending emails and that it is worth to retry.
        Parameters:
        t - The Throwable that should be checked.
        Returns:
        True, if the sending of the email may be successful when retrying after some time.