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

Add support for smtp/smtps and optional port #130

Merged
merged 4 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,12 @@ protected String getRequiredString(final String _name, final String _key) {
}
return ret;
}

protected int getOptionalInt(final String _name, final String _key) {
final String ret = m_ini.get(_name, _key);
if (StringUtils.isEmpty(ret)) {
return -1;
}
return Integer.valueOf(ret);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,18 @@ public synchronized Map<String, ManzanRoute> getRoutes(CamelContext context) {
final String dsn = getRequiredString(name, "dsn");
ret.put(name, new SentryDestination(name, dsn));
break;
case "fluentd":
case "fluentd": {
final String tag = getRequiredString(name, "tag");
final String host = getRequiredString(name, "host");
final int port = getRequiredInt(name, "port");
ret.put(name, new FluentDDestination(name, tag, host, port));
}
break;
case "smtp":
case "smtps":
final String server = getRequiredString(name, "server");
final EmailDestination d = new EmailDestination(name, server, format, getUriAndHeaderParameters(name, sectionObj, "server"), null);
final int port = getOptionalInt(name, "port");
final EmailDestination d = new EmailDestination(name, type, server, format, port, getUriAndHeaderParameters(name, sectionObj, "server", "port"), null);
ret.put(name, d);
break;
case "twilio":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

public class EmailDestination extends ManzanGenericCamelRoute {

public EmailDestination(final String _name, final String _smtpServer, final String _format, final Map<String, String> _uriParams, final Map<String, Object> _headerParams) {
super(_name, "smtps", _smtpServer, _format, _uriParams, _headerParams);
public EmailDestination(final String _name, final String _type, final String _smtpServer, final String _format, final int _port, final Map<String, String> _uriParams, final Map<String, Object> _headerParams) {
super(_name, _type, (_port == -1) ? _smtpServer : _smtpServer + ":" + _port, _format, _uriParams, _headerParams);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Many other destinations will be available. Examples include:
- [AWS Simple Email Service (SES)](https://aws.amazon.com/ses/) ⏳
- [AWS Simple Notification System (SNS)](https://aws.amazon.com/sns/) ⏳
- [ElasticSearch](http://elastic.co) ⏳
- Email (SMTPS) ✅
- Email (SMTP/SMTPS) ✅
- [FluentD](http://fluentd.org) ✅
- [Google Drive](http://drive.google.com) ⏳
- [Google Mail (gmail)](http://gmail.com) ⏳
Expand Down
2 changes: 1 addition & 1 deletion docs/config/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ destinations=<destinations>

Some types have additional properties that they required.

| id | Description | Required properties | Optional props |
| id | Description | Required properties | Optional properties |
|---------|---------------------------------------------|--------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| `file` | Triggered when a file changes | `file` path of file to watch | `filter` only listen for lines that include this value |
| `watch` | Triggered when the Manzan handler is called | `id` of the watch (session ID) | `strwch` is part of the `STRWCH` CL command that can be used to describe how to start the watch when Manzan starts up |
Expand Down
16 changes: 8 additions & 8 deletions docs/config/dests.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ type=<type>

Some types have additional properties that they required.

| id | Description | Required properties |
|----------|---------------------------------|------------------------------------------------------------|
| `stdout` | Write all data to standard out. | None. |
| `slack` | Send data to a Slack channel | * `webhook` <br> * `channel` <br> |
| `fluentd` | Sent data to FluentD | * `tag` <br> * `host` <br> * `port` <br> |
| `smtps` | Sent data via email | * `server` <br> * `subject` <br> * `to` <br> * `from` <br> |
| `sentry` | Send data into Sentry | `dsn` |
| `twilio` | Send via SMS | * `sid` <br> * `token` <br> * `to` <br> * `from` |
| id | Description | Required properties | Optional properties |
|------------------|---------------------------------|------------------------------------------------------------| |
| `stdout` | Write all data to standard out. | None. | |
| `slack` | Send data to a Slack channel | * `webhook` <br> * `channel` <br> | |
| `fluentd` | Sent data to FluentD | * `tag` <br> * `host` <br> * `port` <br> | |
| `smtp`/`smtps` | Sent data via email | * `server` <br> * `subject` <br> * `to` <br> * `from` <br> | * `port` |
| `sentry` | Send data into Sentry | * `dsn` | |
| `twilio` | Send via SMS | * `sid` <br> * `token` <br> * `to` <br> * `from` | |

### Example

Expand Down
Loading