Class MailUtil


  • public class MailUtil
    extends java.lang.Object
    Methods for dealing with the preparation of JavaMail MIME messages. The corresponding send methods of JavaMailSender will take care of the actual creation of a MimeMessage instance. Used primarily by asynchronous Ice services: omero.cmd.mail.SendEmailRequestI.
    Since:
    5.1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.springframework.mail.javamail.JavaMailSender mailSender  
      protected java.lang.String sender  
    • Constructor Summary

      Constructors 
      Constructor Description
      MailUtil​(java.lang.String sender, org.springframework.mail.javamail.JavaMailSender mailSender)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getSender()
      Helper method that returns value of omero.mail.from.
      void sendEmail​(java.lang.String to, java.lang.String topic, java.lang.String body, boolean html, java.util.List<java.lang.String> ccrecipients, java.util.List<java.lang.String> bccrecipients)
      Overloaded method which takes typical email fields as arguments, to prepare and populate the given new MimeMessage instance and send.
      void sendEmail​(java.lang.String from, java.lang.String to, java.lang.String topic, java.lang.String body, boolean html, java.util.List<java.lang.String> ccrecipients, java.util.List<java.lang.String> bccrecipients)
      Main method which takes typical email fields as arguments, to prepare and populate the given new MimeMessage instance and send.
      boolean validateEmail​(java.lang.String email)
      Helper Validate that this address conforms to the syntax rules of RFC 822.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • sender

        protected final java.lang.String sender
      • mailSender

        protected final org.springframework.mail.javamail.JavaMailSender mailSender
    • Constructor Detail

      • MailUtil

        public MailUtil​(java.lang.String sender,
                        org.springframework.mail.javamail.JavaMailSender mailSender)
    • Method Detail

      • getSender

        public java.lang.String getSender()
        Helper method that returns value of omero.mail.from.
      • sendEmail

        public void sendEmail​(java.lang.String from,
                              java.lang.String to,
                              java.lang.String topic,
                              java.lang.String body,
                              boolean html,
                              java.util.List<java.lang.String> ccrecipients,
                              java.util.List<java.lang.String> bccrecipients)
        Main method which takes typical email fields as arguments, to prepare and populate the given new MimeMessage instance and send.
        Parameters:
        from - email address message is sent from
        to - email address message is sent to
        topic - topic of the message
        body - body of the message
        html - flag determines the content type to apply.
        ccrecipients - list of email addresses message is sent as copy to
        bccrecipients - list of email addresses message is sent as blind copy to
      • sendEmail

        public void sendEmail​(java.lang.String to,
                              java.lang.String topic,
                              java.lang.String body,
                              boolean html,
                              java.util.List<java.lang.String> ccrecipients,
                              java.util.List<java.lang.String> bccrecipients)
        Overloaded method which takes typical email fields as arguments, to prepare and populate the given new MimeMessage instance and send. Sender of the email is loaded from omero.mail.from
        Parameters:
        to - email address message is sent to
        topic - topic of the message
        body - body of the message
        html - flag determines the content type to apply.
        ccrecipients - list of email addresses message is sent as copy to
        bccrecipients - list of email addresses message is sent as blind copy to
      • validateEmail

        public boolean validateEmail​(java.lang.String email)
        Helper Validate that this address conforms to the syntax rules of RFC 822.
        Parameters:
        email - email address