Class MailMessage


  • public class MailMessage
    extends Object
    represent a mail message that can be sent via the MailClient
    Author:
    Alexander Lehmann
    • Constructor Detail

      • MailMessage

        public MailMessage()
        construct empty mail message that can be used with the setters
      • MailMessage

        public MailMessage​(MailMessage other)
        copy object to another @link MailMessage object
        Parameters:
        other - object to copy
      • MailMessage

        public MailMessage​(JsonObject json)
        construct object from a JsonObject representation
        Parameters:
        json - json object to copy
      • MailMessage

        public MailMessage​(String from,
                           String to,
                           String subject,
                           String text)
        construct a simple message with text/plain
        Parameters:
        from - from email address
        to - string to email address
        subject - subject of the mail
        text - plain text of the message body
    • Method Detail

      • getBounceAddress

        public String getBounceAddress()
        get bounce address of this mail
        Returns:
        bounce address
      • setBounceAddress

        public MailMessage setBounceAddress​(String bounceAddress)
        set bounce address of this mail
        Parameters:
        bounceAddress - bounce address
        Returns:
        this to be able to use it fluently
      • getFrom

        public String getFrom()
        get from address of this mail
        Returns:
        from address
      • setFrom

        public MailMessage setFrom​(String from)
        set from address of this mail
        Parameters:
        from - from addrss
        Returns:
        this to be able to use it fluently
      • getTo

        public List<String> getTo()
        get list of to addresses
        Returns:
        List of to addresses
      • setTo

        public MailMessage setTo​(List<String> to)
        set list of to addresses
        Parameters:
        to - List of to addresses
        Returns:
        this to be able to use it fluently
      • setTo

        public MailMessage setTo​(String to)
        helper method for single recipient
        Parameters:
        to - to address
        Returns:
        this to be able to use it fluently
      • getCc

        public List<String> getCc()
        get list of cc addresses
        Returns:
        List of cc addresses
      • setCc

        public MailMessage setCc​(List<String> cc)
        set list of cc addresses
        Parameters:
        cc - List of cc addresses
        Returns:
        this to be able to use it fluently
      • setCc

        public MailMessage setCc​(String cc)
        helper method for single recipient
        Parameters:
        cc - cc address
        Returns:
        this to be able to use it fluently
      • getBcc

        public List<String> getBcc()
        get list of bcc addresses
        Returns:
        List of bcc addresses
      • setBcc

        public MailMessage setBcc​(List<String> bcc)
        set list of bcc addresses
        Parameters:
        bcc - List of bcc addresses
        Returns:
        this to be able to use it fluently
      • setBcc

        public MailMessage setBcc​(String bcc)
        helper method for single recipient
        Parameters:
        bcc - bcc address
        Returns:
        this to be able to use it fluently
      • getSubject

        public String getSubject()
        get the subject of this mail
        Returns:
        the subject
      • setSubject

        public MailMessage setSubject​(String subject)
        set the subject of this mail
        Parameters:
        subject - the subject
        Returns:
        this to be able to use it fluently
      • getText

        public String getText()
        get the plain text of this mail
        Returns:
        the text
      • setText

        public MailMessage setText​(String text)
        set the plain text of this mail
        Parameters:
        text - the text
        Returns:
        this to be able to use it fluently
      • getHtml

        public String getHtml()
        get the html text of this mail
        Returns:
        the text
      • setHtml

        public MailMessage setHtml​(String html)
        set the html text of this mail
        Parameters:
        html - the text
        Returns:
        this to be able to use it fluently
      • getAttachment

        public List<MailAttachment> getAttachment()
        get the list of attachments of this mail
        Returns:
        List of attachment
      • setAttachment

        public MailMessage setAttachment​(List<MailAttachment> attachment)
        set the list of attachments of this mail
        Parameters:
        attachment - List of attachment
        Returns:
        this to be able to use it fluently
      • setAttachment

        public MailMessage setAttachment​(MailAttachment attachment)
        set a single attachment of this mail
        Parameters:
        attachment - the attachment to add
        Returns:
        this to be able to use it fluently
      • getInlineAttachment

        public List<MailAttachment> getInlineAttachment()
        get the list of inline attachments of this mail
        Returns:
        List of attachment
      • setInlineAttachment

        public MailMessage setInlineAttachment​(List<MailAttachment> inlineAttachment)
        set the list of inline attachments of this mail
        Parameters:
        inlineAttachment - List of attachment
        Returns:
        this to be able to use it fluently
      • setInlineAttachment

        public MailMessage setInlineAttachment​(MailAttachment inlineAttachment)
        set a single inline attachment of this mail
        Parameters:
        inlineAttachment - the attachment to add
        Returns:
        this to be able to use it fluently
      • addHeader

        public MailMessage addHeader​(String key,
                                     String value)
        Add a message header.
        Parameters:
        key - the header key
        value - the header value
        Returns:
        a reference to this, so the API can be used fluently
      • getHeaders

        public MultiMap getHeaders()
        Get the headers.
        Returns:
        the headers
      • setHeaders

        public MailMessage setHeaders​(MultiMap headers)
        Set the headers.
        Parameters:
        headers - the headers to set
        Returns:
        this to be able to use it fluently
      • isFixedHeaders

        public boolean isFixedHeaders()
        get whether our own headers should be the only headers added to the message
        Returns:
        the fixedHeaders
      • setFixedHeaders

        public MailMessage setFixedHeaders​(boolean fixedHeaders)
        set whether our own headers should be the only headers added to the message
        Parameters:
        fixedHeaders - the fixedHeaders to set
        Returns:
        this to be able to use it fluently
      • toJson

        public JsonObject toJson()
        convert the mail message to Json representation
        Returns:
        the json object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object