-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
1737798
0
2013650523 eedef28
Update pom.xml
2013650523 146fa24
Update plugin-mapping.properties
2013650523 9b1f10b
Update pom.xml
2013650523 8c28e80
add email sink connector
2013650523 ed790c8
Delete seatunnel-connectors-v2/connector-email directory
2013650523 5ba8049
Update plugin-mapping.properties
2013650523 48018fa
Merge branch 'dev' into api-draft
2013650523 2c1bf27
Update plugin-mapping.properties
2013650523 843ba43
Update pom.xml
2013650523 6893447
Create pom.xml
2013650523 aa2cf30
[Connector-V2] Add Kudu source and sink connector
2013650523 42ea0f0
[Connector-V2] Add Kudu source and sink connector
2013650523 097492c
[Connector-V2] Add Email sink connector
2013650523 a010783
Update pom.xml
2013650523 25847b4
Update pom.xml
2013650523 3cf9ef5
Delete seatunnel-connectors-v2/connector-kudu directory
2013650523 a936e3c
Update pom.xml
2013650523 f938db4
Update plugin-mapping.properties
2013650523 83d532c
Update pom.xml
2013650523 7519857
[Connector-V2] update codestyle pom.xml
2013650523 e7c67cc
[Connector-V2] update config
2013650523 db3fdbf
[Connector-V2] update license
2013650523 01c71ec
[Connector-V2] update email package version 1.5.6
2013650523 ba84ee1
[Connector-V2] fix problem on code review
2013650523 cb42f1e
Merge branch 'dev' into connector_lyh
2013650523 b7181b6
[Connector-V2] add Email usage document
2013650523 9e1ef81
Merge remote-tracking branch 'origin/connector_lyh' into connector_lyh
2013650523 a21ac08
Update Email.md
2013650523 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
## Description | ||
|
||
Send the data as a file to email. | ||
|
||
The tested kudu 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="这个是标题" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use Englinsh in content There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done; |
||
email_message_content="这个是内容" | ||
} | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
71 changes: 71 additions & 0 deletions
71
...src/main/java/org/apache/seatunnel/connectors/seatunnel/email/config/EmailSinkConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...r-email/src/main/java/org/apache/seatunnel/connectors/seatunnel/email/sink/EmailSink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this.