Class PutEmail

java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.PutEmail
All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent, org.apache.nifi.processor.Processor

@SupportsBatching @Tags({"email","put","notify","smtp"}) @InputRequirement(INPUT_REQUIRED) @CapabilityDescription("Sends an e-mail to configured recipients for each incoming FlowFile") @SupportsSensitiveDynamicProperties @DynamicProperty(name="mail.propertyName", value="Value for a specific property to be set in the JavaMail Session object", description="Dynamic property names that will be passed to the Mail session. Possible properties can be found in: https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html.", expressionLanguageScope=FLOWFILE_ATTRIBUTES) @SystemResourceConsideration(resource=MEMORY, description="The entirety of the FlowFile\'s content (as a String object) will be read into memory in case the property to use the flow file content as the email body is set to true.") public class PutEmail extends org.apache.nifi.processor.AbstractProcessor
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    private Pattern
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final String
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    private static final Pattern
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.AllowableValue
     
    static final org.apache.nifi.components.PropertyDescriptor
     
     
    static final org.apache.nifi.components.AllowableValue
     
    private static final List<org.apache.nifi.components.PropertyDescriptor>
     
    private static final Map<String,org.apache.nifi.components.PropertyDescriptor>
    Mapping of the mail properties to the NiFi PropertyDescriptors that will be evaluated at runtime
    static final org.apache.nifi.processor.Relationship
     
    static final org.apache.nifi.processor.Relationship
     
    private static final Set<org.apache.nifi.processor.Relationship>
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private jakarta.mail.Session
    Based on the input properties, determine whether an authenticate or unauthenticated session should be used.
    protected Collection<org.apache.nifi.components.ValidationResult>
    customValidate(org.apache.nifi.components.ValidationContext context)
     
    private static String
    formatAttributes(org.apache.nifi.flowfile.FlowFile flowFile, String messagePrepend)
     
    private Charset
    getCharset(org.apache.nifi.processor.ProcessContext context)
    Utility function to get a charset from the INPUT_CHARACTER_SET property
    private String
    getEncoding(org.apache.nifi.processor.ProcessContext context)
    Utility function to get the correct encoding from the INPUT_CHARACTER_SET property
    private Properties
    getMailPropertiesFromFlowFile(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile flowFile)
    Uses the mapping of javax.mail properties to NiFi PropertyDescriptors to build the required Properties object to be used for sending this email
    private String
    getMessage(org.apache.nifi.flowfile.FlowFile flowFile, org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session)
     
    Set<org.apache.nifi.processor.Relationship>
     
    protected org.apache.nifi.components.PropertyDescriptor
     
    protected List<org.apache.nifi.components.PropertyDescriptor>
     
    void
    onScheduled(org.apache.nifi.processor.ProcessContext context)
     
    void
    onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session)
     
    protected void
    send(jakarta.mail.Message msg)
    Wrapper for static method Transport.send(Message) to add testability of this class.
    private void
    setMessageHeader(String header, String value, jakarta.mail.Message message)
     
    private jakarta.mail.internet.InternetAddress[]
    toInetAddresses(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile flowFile, org.apache.nifi.components.PropertyDescriptor propertyDescriptor)
     

    Methods inherited from class org.apache.nifi.processor.AbstractProcessor

    onTrigger

    Methods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor

    getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrue

    Methods inherited from class org.apache.nifi.components.AbstractConfigurableComponent

    equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, onPropertyModified, validate

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.nifi.components.ConfigurableComponent

    getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate

    Methods inherited from interface org.apache.nifi.processor.Processor

    isStateful, migrateProperties, migrateRelationships
  • Field Details

    • MAIL_PROPERTY_PATTERN

      private static final Pattern MAIL_PROPERTY_PATTERN
    • SMTP_HOSTNAME

      public static final org.apache.nifi.components.PropertyDescriptor SMTP_HOSTNAME
    • SMTP_PORT

      public static final org.apache.nifi.components.PropertyDescriptor SMTP_PORT
    • PASSWORD_BASED_AUTHORIZATION_MODE

      public static final org.apache.nifi.components.AllowableValue PASSWORD_BASED_AUTHORIZATION_MODE
    • OAUTH_AUTHORIZATION_MODE

      public static final org.apache.nifi.components.AllowableValue OAUTH_AUTHORIZATION_MODE
    • AUTHORIZATION_MODE

      public static final org.apache.nifi.components.PropertyDescriptor AUTHORIZATION_MODE
    • OAUTH2_ACCESS_TOKEN_PROVIDER

      public static final org.apache.nifi.components.PropertyDescriptor OAUTH2_ACCESS_TOKEN_PROVIDER
    • SMTP_USERNAME

      public static final org.apache.nifi.components.PropertyDescriptor SMTP_USERNAME
    • SMTP_PASSWORD

      public static final org.apache.nifi.components.PropertyDescriptor SMTP_PASSWORD
    • SMTP_AUTH

      public static final org.apache.nifi.components.PropertyDescriptor SMTP_AUTH
    • SMTP_TLS

      public static final org.apache.nifi.components.PropertyDescriptor SMTP_TLS
    • SMTP_SOCKET_FACTORY

      public static final org.apache.nifi.components.PropertyDescriptor SMTP_SOCKET_FACTORY
    • HEADER_XMAILER

      public static final org.apache.nifi.components.PropertyDescriptor HEADER_XMAILER
    • ATTRIBUTE_NAME_REGEX

      public static final org.apache.nifi.components.PropertyDescriptor ATTRIBUTE_NAME_REGEX
    • CONTENT_TYPE

      public static final org.apache.nifi.components.PropertyDescriptor CONTENT_TYPE
    • FROM

      public static final org.apache.nifi.components.PropertyDescriptor FROM
    • TO

      public static final org.apache.nifi.components.PropertyDescriptor TO
    • CC

      public static final org.apache.nifi.components.PropertyDescriptor CC
    • BCC

      public static final org.apache.nifi.components.PropertyDescriptor BCC
    • REPLY_TO

      public static final org.apache.nifi.components.PropertyDescriptor REPLY_TO
    • SUBJECT

      public static final org.apache.nifi.components.PropertyDescriptor SUBJECT
    • MESSAGE

      public static final org.apache.nifi.components.PropertyDescriptor MESSAGE
    • ATTACH_FILE

      public static final org.apache.nifi.components.PropertyDescriptor ATTACH_FILE
    • CONTENT_AS_MESSAGE

      public static final org.apache.nifi.components.PropertyDescriptor CONTENT_AS_MESSAGE
    • INCLUDE_ALL_ATTRIBUTES

      public static final org.apache.nifi.components.PropertyDescriptor INCLUDE_ALL_ATTRIBUTES
    • INPUT_CHARACTER_SET

      public static final org.apache.nifi.components.PropertyDescriptor INPUT_CHARACTER_SET
    • PROPERTY_DESCRIPTORS

      private static final List<org.apache.nifi.components.PropertyDescriptor> PROPERTY_DESCRIPTORS
    • REL_SUCCESS

      public static final org.apache.nifi.processor.Relationship REL_SUCCESS
    • REL_FAILURE

      public static final org.apache.nifi.processor.Relationship REL_FAILURE
    • RELATIONSHIPS

      private static final Set<org.apache.nifi.processor.Relationship> RELATIONSHIPS
    • propertyToContext

      private static final Map<String,org.apache.nifi.components.PropertyDescriptor> propertyToContext
      Mapping of the mail properties to the NiFi PropertyDescriptors that will be evaluated at runtime
    • attributeNamePattern

      private volatile Pattern attributeNamePattern
    • oauth2AccessTokenProvider

      private volatile OAuth2AccessTokenProvider oauth2AccessTokenProvider
    • BODY_SEPARATOR

      public static final String BODY_SEPARATOR
      See Also:
  • Constructor Details

    • PutEmail

      public PutEmail()
  • Method Details

    • getRelationships

      public Set<org.apache.nifi.processor.Relationship> getRelationships()
      Specified by:
      getRelationships in interface org.apache.nifi.processor.Processor
      Overrides:
      getRelationships in class org.apache.nifi.processor.AbstractSessionFactoryProcessor
    • getSupportedPropertyDescriptors

      protected List<org.apache.nifi.components.PropertyDescriptor> getSupportedPropertyDescriptors()
      Overrides:
      getSupportedPropertyDescriptors in class org.apache.nifi.components.AbstractConfigurableComponent
    • getSupportedDynamicPropertyDescriptor

      protected org.apache.nifi.components.PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
      Overrides:
      getSupportedDynamicPropertyDescriptor in class org.apache.nifi.components.AbstractConfigurableComponent
    • customValidate

      protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext context)
      Overrides:
      customValidate in class org.apache.nifi.components.AbstractConfigurableComponent
    • onScheduled

      @OnScheduled public void onScheduled(org.apache.nifi.processor.ProcessContext context)
    • setMessageHeader

      private void setMessageHeader(String header, String value, jakarta.mail.Message message) throws jakarta.mail.MessagingException
      Throws:
      jakarta.mail.MessagingException
    • onTrigger

      public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session)
      Specified by:
      onTrigger in class org.apache.nifi.processor.AbstractProcessor
    • getMessage

      private String getMessage(org.apache.nifi.flowfile.FlowFile flowFile, org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session)
    • createMailSession

      private jakarta.mail.Session createMailSession(Properties properties)
      Based on the input properties, determine whether an authenticate or unauthenticated session should be used. If authenticated, creates a Password Authenticator for use in sending the email.
      Parameters:
      properties - mail properties
      Returns:
      session
    • getMailPropertiesFromFlowFile

      private Properties getMailPropertiesFromFlowFile(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile flowFile)
      Uses the mapping of javax.mail properties to NiFi PropertyDescriptors to build the required Properties object to be used for sending this email
      Parameters:
      context - context
      flowFile - flowFile
      Returns:
      mail properties
    • formatAttributes

      private static String formatAttributes(org.apache.nifi.flowfile.FlowFile flowFile, String messagePrepend)
    • toInetAddresses

      private jakarta.mail.internet.InternetAddress[] toInetAddresses(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile flowFile, org.apache.nifi.components.PropertyDescriptor propertyDescriptor) throws jakarta.mail.internet.AddressException
      Parameters:
      context - the current context
      flowFile - the current flow file
      propertyDescriptor - the property to evaluate
      Returns:
      an InternetAddress[] parsed from the supplied property
      Throws:
      jakarta.mail.internet.AddressException - if the property cannot be parsed to a valid InternetAddress[]
    • send

      protected void send(jakarta.mail.Message msg) throws jakarta.mail.MessagingException
      Wrapper for static method Transport.send(Message) to add testability of this class.
      Parameters:
      msg - the message to send
      Throws:
      jakarta.mail.MessagingException - on error
    • getCharset

      private Charset getCharset(org.apache.nifi.processor.ProcessContext context)
      Utility function to get a charset from the INPUT_CHARACTER_SET property
      Parameters:
      context - the ProcessContext
      Returns:
      the Charset
    • getEncoding

      private String getEncoding(org.apache.nifi.processor.ProcessContext context)
      Utility function to get the correct encoding from the INPUT_CHARACTER_SET property
      Parameters:
      context - the ProcessContext
      Returns:
      the encoding