@SupportsBatching @Tags(value={"email","put","notify","smtp"}) @InputRequirement(value=INPUT_REQUIRED) @CapabilityDescription(value="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 AbstractProcessor
| Modifier and Type | Class and Description |
|---|---|
private static class |
PutEmail.DynamicMailPropertyValidator |
| Constructor and Description |
|---|
PutEmail() |
| Modifier and Type | Method and Description |
|---|---|
private jakarta.mail.Session |
createMailSession(Properties properties)
Based on the input properties, determine whether an authenticate or unauthenticated session should be used.
|
protected Collection<ValidationResult> |
customValidate(ValidationContext context) |
private static String |
formatAttributes(FlowFile flowFile,
String messagePrepend) |
private Charset |
getCharset(ProcessContext context)
Utility function to get a charset from the
INPUT_CHARACTER_SET property |
private String |
getEncoding(ProcessContext context)
Utility function to get the correct encoding from the
INPUT_CHARACTER_SET property |
private Properties |
getMailPropertiesFromFlowFile(ProcessContext context,
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(FlowFile flowFile,
ProcessContext context,
ProcessSession session) |
Set<Relationship> |
getRelationships() |
protected PropertyDescriptor |
getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
protected void |
init(ProcessorInitializationContext context) |
void |
onScheduled(ProcessContext context) |
void |
onTrigger(ProcessContext context,
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(ProcessContext context,
FlowFile flowFile,
PropertyDescriptor propertyDescriptor) |
onTriggergetControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueequals, getPropertyDescriptor, getPropertyDescriptors, hashCode, onPropertyModified, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitisStatefulgetPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validateprivate static final Pattern MAIL_PROPERTY_PATTERN
public static final PropertyDescriptor SMTP_HOSTNAME
public static final PropertyDescriptor SMTP_PORT
public static final AllowableValue PASSWORD_BASED_AUTHORIZATION_MODE
public static final AllowableValue OAUTH_AUTHORIZATION_MODE
public static final PropertyDescriptor AUTHORIZATION_MODE
public static final PropertyDescriptor OAUTH2_ACCESS_TOKEN_PROVIDER
public static final PropertyDescriptor SMTP_USERNAME
public static final PropertyDescriptor SMTP_PASSWORD
public static final PropertyDescriptor SMTP_AUTH
public static final PropertyDescriptor SMTP_TLS
public static final PropertyDescriptor SMTP_SOCKET_FACTORY
public static final PropertyDescriptor HEADER_XMAILER
public static final PropertyDescriptor ATTRIBUTE_NAME_REGEX
public static final PropertyDescriptor CONTENT_TYPE
public static final PropertyDescriptor FROM
public static final PropertyDescriptor TO
public static final PropertyDescriptor CC
public static final PropertyDescriptor BCC
public static final PropertyDescriptor SUBJECT
public static final PropertyDescriptor MESSAGE
public static final PropertyDescriptor ATTACH_FILE
public static final PropertyDescriptor CONTENT_AS_MESSAGE
public static final PropertyDescriptor INCLUDE_ALL_ATTRIBUTES
public static final PropertyDescriptor INPUT_CHARACTER_SET
public static final Relationship REL_SUCCESS
public static final Relationship REL_FAILURE
private List<PropertyDescriptor> properties
private Set<Relationship> relationships
private static final Map<String,PropertyDescriptor> propertyToContext
private volatile Pattern attributeNamePattern
private volatile Optional<OAuth2AccessTokenProvider> oauth2AccessTokenProviderOptional
public static final String BODY_SEPARATOR
protected void init(ProcessorInitializationContext context)
init in class AbstractSessionFactoryProcessorpublic Set<Relationship> getRelationships()
getRelationships in interface ProcessorgetRelationships in class AbstractSessionFactoryProcessorprotected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponentprotected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
getSupportedDynamicPropertyDescriptor in class AbstractConfigurableComponentprotected Collection<ValidationResult> customValidate(ValidationContext context)
customValidate in class AbstractConfigurableComponent@OnScheduled public void onScheduled(ProcessContext context)
private void setMessageHeader(String header, String value, jakarta.mail.Message message) throws jakarta.mail.MessagingException
jakarta.mail.MessagingExceptionpublic void onTrigger(ProcessContext context, ProcessSession session)
onTrigger in class AbstractProcessorprivate String getMessage(FlowFile flowFile, ProcessContext context, ProcessSession session)
private jakarta.mail.Session createMailSession(Properties properties)
properties - mail propertiesprivate Properties getMailPropertiesFromFlowFile(ProcessContext context, FlowFile flowFile)
context - contextflowFile - flowFileprivate jakarta.mail.internet.InternetAddress[] toInetAddresses(ProcessContext context, FlowFile flowFile, PropertyDescriptor propertyDescriptor) throws jakarta.mail.internet.AddressException
context - the current contextflowFile - the current flow filepropertyDescriptor - the property to evaluatejakarta.mail.internet.AddressException - if the property cannot be parsed to a valid InternetAddress[]protected void send(jakarta.mail.Message msg)
throws jakarta.mail.MessagingException
Transport.send(Message) to add testability of this class.msg - the message to sendjakarta.mail.MessagingException - on errorprivate Charset getCharset(ProcessContext context)
INPUT_CHARACTER_SET propertycontext - the ProcessContextprivate String getEncoding(ProcessContext context)
INPUT_CHARACTER_SET propertycontext - the ProcessContextCopyright © 2023 Apache NiFi Project. All rights reserved.