-
-
Notifications
You must be signed in to change notification settings - Fork 808
added SMTP support and removed resend dependency #313
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6c5fe90
added SMTP support and removed resend dependency
Chigala ea9b678
made the types optional based on requested changes
Chigala 242928f
updated the docs to reflect the changes made
Chigala 63f0c45
SMTP_PORT env var has to be coerced to a number
matt-aitken 55c5df6
refactor: improved the smtpConfig validation
Chigala 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -8,7 +8,15 @@ import type { AuthUser } from "./authUser"; | |
import { workerQueue } from "./worker.server"; | ||
|
||
const client = new EmailClient({ | ||
apikey: env.RESEND_API_KEY, | ||
smtpConfig: { | ||
host: env.SMTP_HOST, | ||
secure: true, | ||
port: env.SMTP_PORT, | ||
auth: { | ||
user: env.SMTP_USER, | ||
pass: env.SMTP_PASSWORD, | ||
}, | ||
}, | ||
imagesBaseUrl: env.APP_ORIGIN, | ||
from: env.FROM_EMAIL ?? "[email protected]", | ||
replyTo: env.REPLY_TO_EMAIL ?? "[email protected]", | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -82,9 +82,9 @@ Both of these secrets should be set to the base URL of your fly application. For | |
|
||
 | ||
|
||
`RESEND_API_KEY`, `FROM_EMAIL` and `REPLY_TO_EMAIL` | ||
`FROM_EMAIL`,`REPLY_TO_EMAIL`, `SMTP_HOST`, `SMTP_PORT`, `SMTP_USER` and `SMTP_PASSWORD` | ||
|
||
We use [Resend.com](https://resend.com) for email sending (including the magic-link signup/login system). They have a generous free tier of 100 emails a day that should be sufficient. Signup for Resend.com and enter the environment vars below | ||
We use SMTP for email sending (including the magic-link signup/login system). | ||
|
||
## Set the secrets | ||
|
||
|
@@ -99,7 +99,10 @@ fly secrets set \ | |
APP_ORIGIN="https://<fly app name>.fly.dev" \ | ||
FROM_EMAIL="Acme Inc. <[email protected]>" \ | ||
REPLY_TO_EMAIL="Acme Inc. <[email protected]>" \ | ||
RESEND_API_KEY=<your API Key> \ | ||
SMTP_HOST= < your SMTP host > \ | ||
SMTP_PORT= < your SMTP port > \ | ||
SMTP_USER= < your SMTP user > \ | ||
SMTP_PASSWORD= < your SMTP password > \ | ||
AUTH_GITHUB_CLIENT_ID=<your GitHub OAuth Client ID> \ | ||
AUTH_GITHUB_CLIENT_SECRET=<your GitHUb OAuth Client Secret> | ||
|
||
|
This file contains hidden or 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 hidden or 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
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.
this
smtpConfig
option is always going to be "truthy" so thenodemailer.createTransport
thing is always going to be called: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'm sorry but I don't quite understand this
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.
@ericallam Should I put back the resend api key and dependency as a fallback to when the smtp config doesn't exist?
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 think Eric just meant the config values should be checked instead of the entire object. Otherwise, this will never return
undefined
. Checking for truthysmtpConfig.host
should probably be enough.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.
Ohh, makes sense. Thanks