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 SMTP outbound support to the bridge. #4

Merged
merged 25 commits into from Aug 22, 2021
Merged

Add SMTP outbound support to the bridge. #4

merged 25 commits into from Aug 22, 2021

Conversation

abbyck
Copy link
Owner

@abbyck abbyck commented Jul 16, 2021

  • Currently uses hardcoded 'To' address on the outbound.
  • DKIM signing support is also added.

Signed-off-by: Abhinav Krishna C K me@abhy.me

* Currently uses hardcoded 'To' address on the outbound.
* DKIM signing support is also added.

Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Copy link
Collaborator

@Half-Shot Half-Shot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking on the right path, I've added a bunch of comments that I'd like you to look at first, and I'll review the rest afterwards. I think generally you can get away with using more promises here which is a bit more modern and easier to read and maintain :)

config/config-sample.yaml Outdated Show resolved Hide resolved
src/bridge.js Show resolved Hide resolved
src/bridge.js Outdated Show resolved Hide resolved
src/bridge.js Outdated Show resolved Hide resolved
src/bridge.js Outdated Show resolved Hide resolved
src/email/outbound.js Outdated Show resolved Hide resolved
src/email/outbound.js Outdated Show resolved Hide resolved
src/email/outbound.js Outdated Show resolved Hide resolved
src/email/outbound.js Outdated Show resolved Hide resolved
src/email/outbound.js Outdated Show resolved Hide resolved
Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Includes other cosmetic changes.

Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Remove devHost/devPort and decide on next hop based on smtpHost.
Fix resloved MX records sorting.
Unify tryConnect for resolvedMX and relaying hop.

Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Resolve email from userId.

Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Remove hardcoded 'to' address by getting the joined memebers
and filtering out the email users.
Also, 'from' address is calculated using the roomAlias of the
corresponding bridged room.

Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Currently the display name is not set. This commit
enables to set Matrix display name based on the
'from' header. If that's empty, email ID will be
set as the display name.

Signed-off-by: Abhinav Krishna C K <me@abhy.me>
@Half-Shot Half-Shot self-requested a review August 6, 2021 16:25
Now the bridge will check for STARTSSL availability with connecting SMTP
server and will try to upgrade the connection to use TLS (Opportunistic TLS).

Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Copy link
Collaborator

@Half-Shot Half-Shot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great. I've added a bunch of nits, but it's all suggestions around code styling rather than actual concerns of the logic. This is really exciting to see :)

config/config-sample.yaml Outdated Show resolved Hide resolved
dkimSelector: ''
# Enable Opportunistic TLS support for outbound emails.
startTLS: false
# TLS Key file location
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If any of these are optional, I'd encourage you to put a hash before them and prefixthe description with "Optional: ". Helps us admins out

@@ -3,7 +3,7 @@ required: ["bridge"]
properties:
bridge:
type: "object"
required: ["domain", "homeserverUrl", "mxDomain", "mailPort"]
required: ["domain", "homeserverUrl", "mxDomain", "mailPort", "dkimEnabled", "startTLS"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there is a way to do dependencies, so you must specify TLSKey / TLSCert if you enable startTLS (json-schema/json-schema#158 (comment)). It took me ages to Google for mind.

Another more straight-forward option is to just have a tls object which contains tlskey and tlscert properties which are both requried. If the tls object is not specified, tls is disabled

type: "string"
dkimSelector:
type: "string"
dkimEnabled:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about dependencies. An object might be the way to go.

src/bridge.js Show resolved Hide resolved
src/email/outbound.js Show resolved Hide resolved
src/email/outbound.js Outdated Show resolved Hide resolved
src/email/outbound.js Outdated Show resolved Hide resolved
else {
// check for ESMTP/ignore-case
if (/\besmtp\b/i.test(msg)) {
// TODO: determine AUTH type; auth login, auth crm-md5, auth plain
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: For each of the TODOs you want to do later, make an issue in this repo and link back to it as a comment. It means any community member can:

  1. See what doesn't work yet
  2. See what they can work on to make it work better
  3. Find the code line the issue relates to

src/email/outbound.js Outdated Show resolved Hide resolved
abbyck and others added 12 commits August 14, 2021 19:04
Co-authored-by: Will Hunt <willh@matrix.org>
Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Signed-off-by: Abhinav Krishna C K <me@abhy.me>
'@_email_'.length improves readability by a lot.

Co-authored-by: Will Hunt <willh@matrix.org>
Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Co-authored-by: Will Hunt <willh@matrix.org>
meaningful function name

Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Signed-off-by: Abhinav Krishna C K <me@abhy.me>
Signed-off-by: Abhinav Krishna C K <me@abhy.me>
@abbyck abbyck merged commit f3c65c8 into main Aug 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants