Class EmailMethods


  • public final class EmailMethods
    extends Object
    Provides one-liners for sending and reading emails.
    • Constructor Detail

      • EmailMethods

        @Autowired
        public EmailMethods​(io.toro.martini.email.EmailClient client)
    • Method Detail

      • sendEmail

        public static String sendEmail​(String body,
                                       String protocol,
                                       String login,
                                       String password,
                                       String server,
                                       int port,
                                       String from,
                                       Object to,
                                       String subject)

        Send an email.

        Example usage:

         String body = 'Body of the email.'
         body.sendEmail( 'smtp',
                         'user@gmail.com',
                         'password',
                         'smtp.gmail.com',
                         587,
                         'from@gmail.com',
                         'to@gmail.com',
                         'Subject' )
         

        Parameters:
        body - the body of the email
        protocol - protocol of the email server
        login - email server login
        password - email server password
        server - email server hostname
        port - email server port number
        from - from address
        to - to address (can be String, String[], or Collection<String>)
        subject - email subject
        Returns:
        the body of the email (for chaining)
        Since:
        1.0
      • sendEmail

        public static String sendEmail​(String body,
                                       String protocol,
                                       String login,
                                       String password,
                                       String server,
                                       int port,
                                       String from,
                                       Object to,
                                       String subject,
                                       List<javax.activation.DataSource> attachments)

        Send an email.

        Example usage:

         String body = 'Body of the email.'
         def attachments = ...
         body.sendEmail( 'smtp',
                         'user@gmail.com',
                         'password',
                         'smtp.gmail.com',
                         587,
                         'from@gmail.com',
                         'to@gmail.com',
                         'Subject',
                         attachments )
         

        Parameters:
        body - the body of the email
        protocol - protocol of the email server
        login - email server login
        password - email server password
        server - email server hostname
        port - email server port number
        from - from address
        to - to address (can be String, String[], or Collection<String>)
        subject - email subject
        attachments - optional list of email attachments
        Returns:
        the body of the email (for chaining)
        Since:
        1.0
      • sendEmail

        public static String sendEmail​(String body,
                                       String protocol,
                                       String login,
                                       String password,
                                       String server,
                                       int port,
                                       String from,
                                       Object to,
                                       Object cc,
                                       String subject)

        Send an email.

        Example usage:

         String body = 'Body of the email.'
         body.sendEmail( 'smtp',
                         'user@gmail.com',
                         'password',
                         'smtp.gmail.com',
                         587,
                         'from@gmail.com',
                         'to@gmail.com',
                         [ 'cc1@gmail.com', 'cc2@gmail.com' ],
                         'Subject' )
         

        Parameters:
        body - the body of the email
        protocol - protocol of the email server
        login - email server login
        password - email server password
        server - email server hostname
        port - email server port number
        from - from address
        to - to address (can be String, String[], or Collection<String>)
        cc - CC address (can be String, String[], or Collection<String>)
        subject - email subject
        Returns:
        the body of the email (for chaining)
        Since:
        1.0
      • sendEmail

        public static String sendEmail​(String body,
                                       String protocol,
                                       String login,
                                       String password,
                                       String server,
                                       int port,
                                       String from,
                                       Object to,
                                       Object cc,
                                       String subject,
                                       List<javax.activation.DataSource> attachments)

        Send an email.

        Example usage:

         String body = 'Body of the email.'
         def attachments = ...
         body.sendEmail( 'smtp',
                         'user@gmail.com',
                         'password',
                         'smtp.gmail.com',
                         587,
                         'from@gmail.com',
                         'to@gmail.com',
                         [ 'cc1@gmail.com', 'cc2@gmail.com' ],
                         'Subject',
                         attachments )
         

        Parameters:
        body - the body of the email
        protocol - protocol of the email server
        login - email server login
        password - email server password
        server - email server hostname
        port - email server port number
        from - from address
        to - to address (can be String, String[], or Collection<String>)
        cc - CC address (can be String, String[], or Collection<String>)
        subject - email subject
        attachments - optional list of email attachments
        Returns:
        the body of the email (for chaining)
        Since:
        1.0
      • sendEmail

        public static String sendEmail​(String body,
                                       String protocol,
                                       String login,
                                       String password,
                                       String server,
                                       int port,
                                       String from,
                                       Object to,
                                       Object cc,
                                       Object bcc,
                                       String subject)

        Send an email.

        Example usage:

         String body = 'Body of the email.'
         body.sendEmail( 'smtp',
                         'user@gmail.com',
                         'password',
                         'smtp.gmail.com',
                         587,
                        'from@gmail.com',
                        'to@gmail.com',
                        [ 'cc1@gmail.com', 'cc2@gmail.com' ],
                        [ 'bcc1@gmail.com', 'bcc2@gmail.com' ],
                        'Subject' )
         

        Parameters:
        body - the body of the email
        protocol - protocol of the email server
        login - email server login
        password - email server password
        server - email server hostname
        port - email server port number
        from - from address
        to - to address (can be String, String[], or Collection<String>)
        cc - optional CC address (can be String, String[], or Collection<String>)
        bcc - optional BCC address (can be String, String[], or Collection<String>)
        subject - email subject
        Returns:
        the body of the email (for chaining)
        Since:
        1.0
      • sendEmail

        public static String sendEmail​(String body,
                                       String protocol,
                                       String login,
                                       String password,
                                       String server,
                                       int port,
                                       String from,
                                       Object to,
                                       Object cc,
                                       Object bcc,
                                       String subject,
                                       List<javax.activation.DataSource> attachments)

        Send an email.

        Example usage:

         String body = 'Body of the email.'
         def attachments = ...
         body.sendEmail( 'smtp',
                         'user@gmail.com',
                         'password',
                         'smtp.gmail.com',
                         587,
                         'from@gmail.com',
                         'to@gmail.com',
                         [ 'cc1@gmail.com', 'cc2@gmail.com' ],
                         null,
                         'Subject',
                         attachments )
         
        Parameters:
        body - the body of the email
        protocol - protocol of the email server
        login - email server login
        password - email server password
        server - email server hostname
        port - email server port number
        from - from address
        to - to address (can be String, String[], or Collection<String>)
        cc - optional CC address (can be String, String[], or Collection<String>)
        bcc - optional BCC address (can be String, String[], or Collection<String>)
        subject - email subject
        attachments - optional list of email attachments
        Returns:
        the body of the email (for chaining)
        Since:
        1.0