Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Connector-V2] Add Email sink connector #2304

Merged
merged 29 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1737798
0
2013650523 Jul 22, 2022
eedef28
Update pom.xml
2013650523 Jul 23, 2022
146fa24
Update plugin-mapping.properties
2013650523 Jul 23, 2022
9b1f10b
Update pom.xml
2013650523 Jul 23, 2022
8c28e80
add email sink connector
2013650523 Jul 23, 2022
ed790c8
Delete seatunnel-connectors-v2/connector-email directory
2013650523 Jul 23, 2022
5ba8049
Update plugin-mapping.properties
2013650523 Jul 23, 2022
48018fa
Merge branch 'dev' into api-draft
2013650523 Jul 23, 2022
2c1bf27
Update plugin-mapping.properties
2013650523 Jul 25, 2022
843ba43
Update pom.xml
2013650523 Jul 25, 2022
6893447
Create pom.xml
2013650523 Jul 25, 2022
aa2cf30
[Connector-V2] Add Kudu source and sink connector
2013650523 Jul 29, 2022
42ea0f0
[Connector-V2] Add Kudu source and sink connector
2013650523 Jul 29, 2022
097492c
[Connector-V2] Add Email sink connector
2013650523 Jul 30, 2022
a010783
Update pom.xml
2013650523 Jul 30, 2022
25847b4
Update pom.xml
2013650523 Jul 30, 2022
3cf9ef5
Delete seatunnel-connectors-v2/connector-kudu directory
2013650523 Jul 30, 2022
a936e3c
Update pom.xml
2013650523 Jul 30, 2022
f938db4
Update plugin-mapping.properties
2013650523 Jul 30, 2022
83d532c
Update pom.xml
2013650523 Jul 30, 2022
7519857
[Connector-V2] update codestyle pom.xml
2013650523 Aug 1, 2022
e7c67cc
[Connector-V2] update config
2013650523 Aug 2, 2022
db3fdbf
[Connector-V2] update license
2013650523 Aug 2, 2022
01c71ec
[Connector-V2] update email package version 1.5.6
2013650523 Aug 2, 2022
ba84ee1
[Connector-V2] fix problem on code review
2013650523 Aug 2, 2022
cb42f1e
Merge branch 'dev' into connector_lyh
2013650523 Aug 3, 2022
b7181b6
[Connector-V2] add Email usage document
2013650523 Aug 3, 2022
9e1ef81
Merge remote-tracking branch 'origin/connector_lyh' into connector_lyh
2013650523 Aug 3, 2022
a21ac08
Update Email.md
2013650523 Aug 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions docs/en/connector-v2/source/Email.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Email

## Description

Send the data as a file to email.

The tested email version is 1.5.6.

## Options

| name | type | required | default value |
|--------------------------|---------|----------|---------------|
| email_from_address | string | yes | - |
| email_to_address | string | yes | - |
| email_host | string | yes | - |
| email_transport_protocol | string | yes | - |
| email_smtp_auth | string | yes | - |
| email_authorization_code | string | yes | - |
| email_message_headline | string | yes | - |
| email_message_content | string | yes | - |


### email_from_address [string]

Sender Email Address .

### email_to_address [string]

Address to receive mail.

### email_host [string]

SMTP server to connect to.

### email_transport_protocol [string]

The protocol to load the session .

### email_smtp_auth [string]

Whether to authenticate the customer.

### email_authorization_code [string]

authorization code,You can obtain the authorization code from the mailbox Settings.

### email_message_headline [string]

The subject line of the entire message.

### email_message_content [string]

The body of the entire message.


## Example

```bash

EmailSink {
email_from_address = "xxxxxx@qq.com"
email_to_address = "xxxxxx@163.com"
email_host="smtp.qq.com"
email_transport_protocol="smtp"
email_smtp_auth="true"
email_authorization_code=""
email_message_headline=""
email_message_content=""
}

```
1 change: 1 addition & 0 deletions plugin-mapping.properties
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ seatunnel.sink.Clickhouse = connector-clickhouse
seatunnel.sink.ClickhouseFile = connector-clickhouse
seatunnel.source.Jdbc = connector-jdbc
seatunnel.sink.Jdbc = connector-jdbc
seatunnel.sink.Email = connector-email
seatunnel.sink.HdfsFile = connector-file-hadoop
seatunnel.sink.LocalFile = connector-file-local
seatunnel.source.Pulsar = connector-pulsar
Expand Down
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
<mongo-spark.version>2.2.0</mongo-spark.version>
<spark-redis.version>2.6.0</spark-redis.version>
<commons-lang3.version>3.4</commons-lang3.version>
<email.version>1.5.6</email.version>
<commons-collections4.version>4.4</commons-collections4.version>
<maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
<spark.scope>provided</spark.scope>
Expand Down Expand Up @@ -263,7 +264,12 @@
<artifactId>lz4</artifactId>
<version>1.3.0</version>
</dependency>

<!--email -->
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>${email.version}</version>
</dependency>
<!--flink-->
<dependency>
<groupId>org.apache.flink</groupId>
Expand Down Expand Up @@ -1322,4 +1328,4 @@
</plugins>
</build>

</project>
</project>
5 changes: 5 additions & 0 deletions seatunnel-connectors-v2-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@
<artifactId>connector-dingtalk</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>connector-email</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
49 changes: 49 additions & 0 deletions seatunnel-connectors-v2/connector-email/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

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.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>seatunnel-connectors-v2</artifactId>
<groupId>org.apache.seatunnel</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>connector-email</artifactId>

<dependencies>
<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>connector-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
</dependency>
<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>seatunnel-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* 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 org.apache.seatunnel.connectors.seatunnel.email.config;

import org.apache.seatunnel.shade.com.typesafe.config.Config;

import lombok.Data;
import lombok.NonNull;

@Data
public class EmailSinkConfig {

private static final String EMAIL_FROM_ADDRESS = "email_from_address";
private static final String EMAIL_TO_ADDRESS = "email_to_address";
private static final String EMAIL_AUTHORIZATION_CODE = "email_authorization_code";
private static final String EMAIL_MESSAGE_HEADLINE = "email_message_headline";
private static final String EMAIL_MESSAGE_CONTENT = "email_message_content";
private static final String EMAIL_HOST = "email_host";
private static final String EMAIL_TRANSPORT_PROTOCOL = "email_transport_protocol";
private static final String EMAIL_SMTP_AUTH = "email_smtp_auth";
private String emailFromAddress;
private String emailToAddress;
private String emailAuthorizationCode;
private String emailMessageHeadline;
private String emailMessageContent;
private String emailHost;
private String emailTransportProtocol;
private String emailSmtpAuth;

public EmailSinkConfig(@NonNull Config pluginConfig) {
if (pluginConfig.hasPath(EMAIL_FROM_ADDRESS)) {
this.emailFromAddress = pluginConfig.getString(EMAIL_FROM_ADDRESS);
}
if (pluginConfig.hasPath(EMAIL_TO_ADDRESS)) {
this.emailToAddress = pluginConfig.getString(EMAIL_TO_ADDRESS);
}
if (pluginConfig.hasPath(EMAIL_AUTHORIZATION_CODE)) {
this.emailAuthorizationCode = pluginConfig.getString(EMAIL_AUTHORIZATION_CODE);
}
if (pluginConfig.hasPath(EMAIL_MESSAGE_HEADLINE)) {
this.emailMessageHeadline = pluginConfig.getString(EMAIL_MESSAGE_HEADLINE);
}
if (pluginConfig.hasPath(EMAIL_MESSAGE_CONTENT)) {
this.emailMessageContent = pluginConfig.getString(EMAIL_MESSAGE_CONTENT);
}
if (pluginConfig.hasPath(EMAIL_HOST)) {
this.emailHost = pluginConfig.getString(EMAIL_HOST);
}
if (pluginConfig.hasPath(EMAIL_TRANSPORT_PROTOCOL)) {
this.emailTransportProtocol = pluginConfig.getString(EMAIL_TRANSPORT_PROTOCOL);
}
if (pluginConfig.hasPath(EMAIL_SMTP_AUTH)) {
this.emailSmtpAuth = pluginConfig.getString(EMAIL_SMTP_AUTH);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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 org.apache.seatunnel.connectors.seatunnel.email.sink;

import org.apache.seatunnel.api.sink.SeaTunnelSink;
import org.apache.seatunnel.api.sink.SinkWriter;
import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
import org.apache.seatunnel.api.table.type.SeaTunnelRow;
import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSimpleSink;
import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;

import org.apache.seatunnel.shade.com.typesafe.config.Config;

import com.google.auto.service.AutoService;

@AutoService(SeaTunnelSink.class)
public class EmailSink extends AbstractSimpleSink<SeaTunnelRow, Void> {

private Config pluginConfig;
private SeaTunnelRowType seaTunnelRowType;

@Override
public void setTypeInfo(SeaTunnelRowType seaTunnelRowType) {
this.seaTunnelRowType = seaTunnelRowType;
}

@Override
public SeaTunnelDataType<SeaTunnelRow> getConsumedType() {
return this.seaTunnelRowType;
}

@Override
public AbstractSinkWriter<SeaTunnelRow, Void> createWriter(SinkWriter.Context context) {
return new EmailSinkWriter(seaTunnelRowType, pluginConfig);
}

@Override
public String getPluginName() {
return "EmailSink";
}

@Override
public void prepare(Config pluginConfig) {
this.pluginConfig = pluginConfig;
}

}
Loading