Interface MailService

  • All Superinterfaces:
    ADEPT2Service

    public interface MailService
    extends ADEPT2Service
    The mail service provides the means to send mails including attachments. Although this mail service supports arbitrary implementations, these implementations are subject of restrictions:
    Since this service is one of the first started services, it must not rely on other services being available except data sources ( JDBCDataSource). This is due to the fact, that some early services like the licence manager or even the security manager may use this service to notify about problems via mail. If you need to use other services you will have to implement MailService. This service is started later and may rely on other services. For instance you can access the log manager or even the execution manager from there.

    No services other than the early started ones should use this interface! Use MailService instead.

    Immediate problems occurring when sending the mail will be indicated by the corresponding receiver being returned together with the exception. However, usually not all problems can be determined at once. For instance, a mail server usually tries to send a mail several times before aborting. Determining a problem also depends heavily on the implementation of the MailService.

    • Method Detail

      • verifyEmailAddress

        SerialisablePair<String,​String> verifyEmailAddress​(String address)
        Verifies the designated (email) address and returns the message and localised message of the corresponding exception/cause for an invalid address or null in case of a valid address.
        Parameters:
        address - The (email) address which to verify.
        Returns:
        The message and localised message of the corresponding exception/cause for an invalid address or null in case of a valid address.
      • sendMail

        EmailResult sendMail​(SessionToken session,
                             List<String> to,
                             String subject,
                             String body,
                             boolean allowAsyncRetry)
        Sends a mail to the designated recipients having the designated subject and the designated body. As sender the configured sender of this service implementation will be used.

        Note that the mail will be sent as one message to all the recipients, i.e. if you need single results for every recipient you need to call this method with a singleton list!

        Parameters:
        session - The session which is used to check for access rights on this method.
        to - The recipients of the mail. This must be at least one valid mail address.
        subject - The subject of the mail. This must not be null.
        body - The body text of the mail. This must not be null.
        allowAsyncRetry - Whether sending the e-mail can be retried asynchronously (after returning from this method) in case of a recoverable problem. Neither the e-mail nor the corresponding exception will in the result.
        Returns:
        The result of the e-mail sending will be returned. If no problems occurred, and sending the mail was not retried, the sent e-mail message could be found in the EmailResult. If there were problems sending the mail (to all recipients), the reason for failing and whether a later retry would make sense could be found in the EmailResult. Neither the e-mail nor the exception will be in the result if asynchronous retry is allowed and an exception occurred for which a retry is sensible.
      • sendMail

        EmailResult sendMail​(SessionToken session,
                             List<String> to,
                             String subject,
                             String body,
                             Map<String,​String> addAttributes,
                             boolean allowAsyncRetry)
        Sends a mail to the designated recipients having the designated subject and the designated body and the optional additional attributes. As sender the configured sender of this service implementation will be used.

        Note that the mail will be sent as one message to all the recipients, i.e. if you need single results for every recipient you need to call this method with a singleton list!

        Parameters:
        session - The session which is used to check for access rights on this method.
        to - The recipients of the mail. This must be at least one valid mail address.
        subject - The subject of the mail. This must not be null.
        body - The body text of the mail. This must not be null.
        addAttributes - Additional, service-specific attributes. The service is free to support additional attributes. Since these attributes depend on the service implementation, the callers may need to know the used service implementation.
        This may be null.
        allowAsyncRetry - Whether sending the e-mail can be retried asynchronously (after returning from this method) in case of a recoverable problem. Neither the e-mail nor the corresponding exception will in the result.
        Returns:
        The result of the e-mail sending will be returned. If no problems occurred, and sending the mail was not retried, the sent e-mail message could be found in the EmailResult. If there were problems sending the mail (to all recipients), the reason for failing and whether a later retry would make sense could be found in the EmailResult. Neither the e-mail nor the exception will be in the result if asynchronous retry is allowed and an exception occurred for which a retry is sensible.
      • sendMail

        EmailResult sendMail​(SessionToken session,
                             List<String> to,
                             List<String> cc,
                             List<String> bcc,
                             String subject,
                             String body,
                             Map<String,​String> addAttributes,
                             boolean allowAsyncRetry)
        Sends a mail to the designated recipients having the designated subject and the designated body and the optional additional attributes. As sender the configured sender of this service implementation will be used.

        Note that the mail will be sent as one message to all the recipients, i.e. if you need single results for every recipient you need to call this method with a singleton list!

        Parameters:
        session - The session which is used to check for access rights on this method.
        to - The recipients of the mail. This must be at least one valid mail address.
        cc - The copy recipients of the mail. This may be null.
        bcc - The blind copy recipients of the mail. This may be null.
        subject - The subject of the mail. This must not be null.
        body - The body text of the mail. This must not be null.
        addAttributes - Additional, service-specific attributes. The service is free to support additional attributes. Since these attributes depend on the service implementation, the callers may need to know the used service implementation.
        This may be null.
        allowAsyncRetry - Whether sending the e-mail can be retried asynchronously (after returning from this method) in case of a recoverable problem. Neither the e-mail nor the corresponding exception will in the result.
        Returns:
        The result of the e-mail sending will be returned. If no problems occurred, and sending the mail was not retried, the sent e-mail message could be found in the EmailResult. If there were problems sending the mail (to all recipients), the reason for failing and whether a later retry would make sense could be found in the EmailResult. Neither the e-mail nor the exception will be in the result if asynchronous retry is allowed and an exception occurred for which a retry is sensible.
      • sendMail

        EmailResult sendMail​(SessionToken session,
                             String from,
                             List<String> to,
                             List<String> cc,
                             List<String> bcc,
                             String subject,
                             String body,
                             boolean allowAsyncRetry)
        Sends a mail to the designated recipients having the designated sender, subject and body.

        Note that the mail will be sent as one message to all the recipients, i.e. if you need single results for every recipient you need to call this method with a singleton list!

        Parameters:
        session - The session which is used to check for access rights on this method.
        from - The mail-address of the sender of the message. This must be a valid mail address.
        to - The recipients of the mail. This must be at least one valid mail address.
        cc - The copy recipients of the mail. This may be null.
        bcc - The blind copy recipients of the mail. This may be null.
        subject - The subject of the mail. This must not be null.
        body - The body text of the mail. This must not be null.
        allowAsyncRetry - Whether sending the e-mail can be retried asynchronously (after returning from this method) in case of a recoverable problem. Neither the e-mail nor the corresponding exception will in the result.
        Returns:
        The result of the e-mail sending will be returned. If no problems occurred, and sending the mail was not retried, the sent e-mail message could be found in the EmailResult. If there were problems sending the mail (to all recipients), the reason for failing and whether a later retry would make sense could be found in the EmailResult. Neither the e-mail nor the exception will be in the result if asynchronous retry is allowed and an exception occurred for which a retry is sensible.
      • sendMail

        EmailResult sendMail​(SessionToken session,
                             String from,
                             List<String> to,
                             List<String> cc,
                             List<String> bcc,
                             String subject,
                             String body,
                             List<SerialisableAttachment> attachments,
                             Map<String,​String> addAttributes,
                             boolean allowAsyncRetry)
        Sends a mail to the designated recipients having the designated sender, subject and body. The designated attachments will be appended to the mail if there are any. If there are additional attributes the service implementation may use them.

        Note that the mail will be sent as one message to all the recipients, i.e. if you need single results for every recipient you need to call this method with singleton lists!

        Parameters:
        session - The session which is used to check for access rights on this method.
        from - The mail-address of the sender of the message. This must be a valid mail address.
        to - The recipients of the mail. This must be at least one valid mail address.
        cc - The copy recipients of the mail. This may be null.
        bcc - The blind copy recipients of the mail. This may be null.
        subject - The subject of the mail. This must not be null.
        body - The body text of the mail. This must not be null.
        attachments - The attachments of the mail.
        This may be null.
        addAttributes - Additional, service-specific attributes. The service is free to support additional attributes. Since these attributes depend on the service implementation, the callers may need to know the used service implementation.
        This may be null.
        allowAsyncRetry - Whether sending the e-mail can be retried asynchronously (after returning from this method) in case of a recoverable problem. Neither the e-mail nor the corresponding exception will in the result.
        Returns:
        The result of the e-mail sending will be returned. If no problems occurred, and sending the mail was not retried, the sent e-mail message could be found in the EmailResult. If there were problems sending the mail (to all recipients), the reason for failing and whether a later retry would make sense could be found in the EmailResult. Neither the e-mail nor the exception will be in the result if asynchronous retry is allowed and an exception occurred for which a retry is sensible.
      • sendMail

        EmailResult sendMail​(SessionToken session,
                             List<String> to,
                             List<String> cc,
                             List<String> bcc,
                             String subject,
                             String body,
                             List<SerialisableAttachment> attachments,
                             Map<String,​String> addAttributes,
                             boolean allowAsyncRetry)
        Sends a mail to the designated recipients having the designated subject and body and the default sender from the MailService. The designated attachments will be appended to the mail if there are any. If there are additional attributes the service implementation may use them.

        Note that the mail will be sent as one message to all the recipients, i.e. if you need single results for every recipient you need to call this method with singleton lists!

        Parameters:
        session - The session which is used to check for access rights on this
        to - The recipients of the mail. This must be at least one valid mail address.
        cc - The copy recipients of the mail. This may be null.
        bcc - The blind copy recipients of the mail. This may be null.
        subject - The subject of the mail. This must not be null.
        body - The body text of the mail. This must not be null.
        attachments - The attachments of the mail. This may be null.
        addAttributes - Additional, service-specific attributes. The service is free to support additional attributes. Since these attributes depend on the service implementation, the callers may need to know the used service implementation.
        This may be null.
        allowAsyncRetry - Whether sending the e-mail can be retried asynchronously (after returning from this method) in case of a recoverable problem. Neither the e-mail nor the corresponding exception will in the result.
        Returns:
        The result of the e-mail sending will be returned. If no problems occurred, and sending the mail was not retried, the sent e-mail message could be found in the EmailResult. If there were problems sending the mail (to all recipients), the reason for failing and whether a later retry would make sense could be found in the EmailResult. Neither the e-mail nor the exception will be in the result if asynchronous retry is allowed and an exception occurred for which a retry is sensible.
      • sendMail

        EmailResult sendMail​(SessionToken session,
                             Email mail,
                             boolean allowAsyncRetry)
        Sends the designated mail which needs at least one recipient, a subject and a body/text. The sender is required but may be set by this mail service.

        Note that the mail will be sent as one message to all the recipients, i.e. if you need single results for every recipient you need to send the mails individually.

        Parameters:
        session - The session which is used to check for access rights on this method.
        mail - The mail which to send containing at least one recipient, a subject and a body/text.
        allowAsyncRetry - Whether sending the e-mail can be retried asynchronously (after returning from this method) in case of a recoverable problem. Neither the e-mail nor the corresponding exception will in the result.
        Returns:
        The result of the e-mail sending will be returned. If no problems occurred, and sending the mail was not retried, the sent e-mail message could be found in the EmailResult. If there were problems sending the mail (to all recipients), the reason for failing and whether a later retry would make sense could be found in the EmailResult. Neither the e-mail nor the exception will be in the result if asynchronous retry is allowed and an exception occurred for which a retry is sensible.
      • sendMail

        EmailResult sendMail​(SessionToken session,
                             Email mail,
                             Map<String,​String> addAttributes,
                             boolean allowAsyncRetry)
        Sends the designated mail which needs at least one recipient, a subject and a body/text. The sender is required but may be set by this mail service. If there are additional attributes the service implementation may use them.

        Note that the mail will be sent as one message to all the recipients, i.e. if you need single results for every recipient you need to send the mails individually.

        Parameters:
        session - The session which is used to check for access rights on this method.
        mail - The mail which to send containing at least one recipient, a subject and a body/text.
        addAttributes - Additional, service-specific attributes. The service is free to support additional attributes. Since these attributes depend on the service implementation, the callers may need to know the used service implementation.
        This may be null.
        allowAsyncRetry - Whether sending the e-mail can be retried asynchronously (after returning from this method) in case of a recoverable problem. Neither the e-mail nor the corresponding exception will in the result.
        Returns:
        The result of the e-mail sending will be returned. If no problems occurred, and sending the mail was not retried, the sent e-mail message could be found in the EmailResult. If there were problems sending the mail (to all recipients), the reason for failing and whether a later retry would make sense could be found in the EmailResult. Neither the e-mail nor the exception will be in the result if asynchronous retry is allowed and an exception occurred for which a retry is sensible.