-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Abhishek kushwaha <abhishekkushwaha1479@gmail.com>
- Loading branch information
1 parent
bbd5369
commit d0cdf34
Showing
7 changed files
with
113 additions
and
0 deletions.
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,15 @@ | ||
import * as React from 'react' | ||
import { Html } from '@react-email/html' | ||
import { Button } from '@react-email/button' | ||
|
||
export function Email(props: { url: string }) { | ||
const { url } = props | ||
|
||
return ( | ||
<Html lang="en"> | ||
<Button href={url}>Click me</Button> | ||
</Html> | ||
) | ||
} | ||
|
||
export default Email |
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,38 @@ | ||
import { Resend } from 'resend' | ||
|
||
import { env } from '../env' | ||
|
||
export const resend = new Resend(env.RESEND_API_KEY) | ||
|
||
export interface Emails { | ||
react: JSX.Element | ||
subject: string | ||
to: string[] | ||
from: string | ||
} | ||
|
||
export type EmailHtml = { | ||
html: string | ||
subject: string | ||
to: string[] | ||
from: string | ||
} | ||
export const sendEmail = async (email: Emails) => { | ||
await resend.emails.send(email) | ||
} | ||
|
||
export const sendEmailHtml = async (email: EmailHtml) => { | ||
await fetch('https://api.resend.com/emails', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${env.RESEND_API_KEY}` | ||
}, | ||
body: JSON.stringify({ | ||
to: email.to, | ||
from: email.from, | ||
subject: email.subject, | ||
html: email.html | ||
}) | ||
}) | ||
} |
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,8 @@ | ||
export const validateEmailNotDisposable = async (mailHost: string) => { | ||
const response = await fetch( | ||
`https://open.kickbox.com/v1/disposable/${mailHost}` | ||
) | ||
const status = await response.json() | ||
|
||
return status.disposable | ||
} |
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,11 @@ | ||
import { createEnv } from '@t3-oss/env-core' | ||
import { z } from 'zod' | ||
|
||
export const env = createEnv({ | ||
server: { | ||
RESEND_API_KEY: z.string().min(1) | ||
}, | ||
runtimeEnv: { | ||
RESEND_API_KEY: process.env.RESEND_API_KEY | ||
} | ||
}) |
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,5 @@ | ||
import { validateEmailNotDisposable } from './emails/utils/utils' | ||
|
||
export { validateEmailNotDisposable } | ||
|
||
export { sendEmail, sendEmailHtml } from './emails/send' |
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,30 @@ | ||
{ | ||
"name": "@repo/emails", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "./index.ts", | ||
"scripts": { | ||
"dev:email": "email dev" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@react-email/button": "^0.0.15", | ||
"@react-email/components": "^0.0.17", | ||
"@react-email/head": "^0.0.8", | ||
"@react-email/html": "^0.0.8", | ||
"@react-email/tailwind": "^0.0.16", | ||
"@t3-oss/env-core": "^0.10.1", | ||
"react-email": "^2.1.2", | ||
"resend": "^3.2.0", | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@repo/typescript-config": "workspace:*", | ||
"@types/node": "20.8.0", | ||
"@types/react": "18.2.64", | ||
"react": "18.2.0", | ||
"typescript": "5.4.5" | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"extends": "@repo/typescript-config/react-library.json", | ||
"include": [".", "env.ts"], | ||
"exclude": ["dist", "build", "node_modules"] | ||
} | ||
|