com.datatorrent.lib.io.SmtpOutputOperator Maven / Gradle / Ivy
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.datatorrent.lib.io;
import java.util.Arrays;
import java.util.Map;
import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.lang.StringUtils;
import com.google.common.collect.Maps;
import com.datatorrent.api.Context.OperatorContext;
import com.datatorrent.api.DefaultInputPort;
import com.datatorrent.common.util.BaseOperator;
/**
* This operator outputs data to an smtp server.
*
* @displayName Smtp Output
* @category Output
* @tags stmp, output operator
*
* @since 0.3.2
*/
@org.apache.hadoop.classification.InterfaceStability.Evolving
public class SmtpOutputOperator extends BaseOperator
{
public enum RecipientType
{
TO, CC, BCC
}
private static final Logger LOG = LoggerFactory.getLogger(SmtpOutputOperator.class);
@NotNull
private String subject;
@NotNull
private String content;
@NotNull
private String from;
private Map recipients = Maps.newHashMap();
private int smtpPort = 587;
@NotNull
private String smtpHost;
private String smtpUserName;
private String smtpPassword;
private String contentType = "text/plain";
private boolean useSsl = false;
private boolean setupCalled = false;
protected transient Properties properties = System.getProperties();
protected transient Authenticator auth;
protected transient Session session;
protected transient Message message;
/**
* This is the port which receives the tuples that will be output to an smtp server.
*/
public final transient DefaultInputPort
© 2015 - 2025 Weber Informatics LLC | Privacy Policy