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
Conversation
* Currently uses hardcoded 'To' address on the outbound. * DKIM signing support is also added. Signed-off-by: Abhinav Krishna C K <me@abhy.me>
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.
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 :)
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>
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>
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.
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
dkimSelector: '' | ||
# Enable Opportunistic TLS support for outbound emails. | ||
startTLS: false | ||
# TLS Key file location |
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.
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
config/email-config-schema.yaml
Outdated
@@ -3,7 +3,7 @@ required: ["bridge"] | |||
properties: | |||
bridge: | |||
type: "object" | |||
required: ["domain", "homeserverUrl", "mxDomain", "mailPort"] | |||
required: ["domain", "homeserverUrl", "mxDomain", "mailPort", "dkimEnabled", "startTLS"] |
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.
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
config/email-config-schema.yaml
Outdated
type: "string" | ||
dkimSelector: | ||
type: "string" | ||
dkimEnabled: |
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.
Same comment about dependencies. An object might be the way to go.
else { | ||
// check for ESMTP/ignore-case | ||
if (/\besmtp\b/i.test(msg)) { | ||
// TODO: determine AUTH type; auth login, auth crm-md5, auth plain |
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.
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:
- See what doesn't work yet
- See what they can work on to make it work better
- Find the code line the issue relates to
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>
meaningful function name Signed-off-by: Abhinav Krishna C K <me@abhy.me>
…ail into smtpoutbound
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