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

✨ Resend #57

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Binary file modified bun.lockb
Binary file not shown.
22 changes: 11 additions & 11 deletions inngest/createSendEmail.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import apiInstance from '@/src/emails/transporter'
import { SendSmtpEmail } from '@sendinblue/client'
import { resend } from '@/src/emails/transporter'

export const sendEmail = async (
email: string,
html: string,
subject: string,
) => {
const sendSmptMail = new SendSmtpEmail()
try {
const res = await resend.emails.send({
from: 'eniszej@gmail.com',
to: [email],
subject,
html,
})

sendSmptMail.to = [{ email }]
sendSmptMail.htmlContent = html
sendSmptMail.sender = {
email: 'eniszej@gmail.com',
name: 'Event Wizard',
return res
} catch (e) {
console.log(e)
}
sendSmptMail.subject = subject

return await apiInstance.sendTransacEmail(sendSmptMail)
}
6 changes: 2 additions & 4 deletions inngest/sendEventReminderEmail.tsx
Original file line number Diff line number Diff line change
@@ -35,16 +35,14 @@ export const sendEventReminderEmail = inngest.createFunction(

const days = differenceInCalendarDays(event.date, new Date())

const { response } = await sendEmail(
const res = await sendEmail(
user.email,
html,
`Erinnerung: Fussball in ${days} Tagen, ${participantsAmount}/${event.maxParticipants} Teilnehmer!`,
)

console.log(
`Message sent to: ${JSON.stringify(user.email)}, Code : ${
response.statusCode
}`,
`Message sent to: ${JSON.stringify(user.email)}, Id: ${res?.id}`,
)
},
)
4 changes: 2 additions & 2 deletions inngest/sendGroupRequestEmail.tsx
Original file line number Diff line number Diff line change
@@ -15,11 +15,11 @@ export const sendGroupRequestEmail = async ({

const html = render(<GroupRequestEmail email={requester} token={token} />)

const { response } = await sendEmail(
const response = await sendEmail(
'eniszej@gmail.com',
html,
'Neue Gruppenanfrage',
)

return { success: response.statusCode === 201 }
return { success: response?.id }
}
6 changes: 2 additions & 4 deletions inngest/sendNewEventEmail.tsx
Original file line number Diff line number Diff line change
@@ -26,16 +26,14 @@ export const sendNewEventEmail = inngest.createFunction(

const html = render(<NewEvent event={event} userName={user.name} />)

const { response } = await sendEmail(
const response = await sendEmail(
user.email,
html,
`NEUES FUSSBALL EVENT: In ${days} Tagen`,
)

console.log(
`Message sent to: ${JSON.stringify(user.email)}, Code : ${
response.statusCode
}`,
`Message sent to: ${JSON.stringify(user.email)}, Code : ${response?.id}`,
)
},
)
12 changes: 3 additions & 9 deletions inngest/sendPaidButCanceledMail.tsx
Original file line number Diff line number Diff line change
@@ -21,17 +21,11 @@ export const sendPaidButCanceledMail = async (

if (!owner) return { success: false }

const { response } = await sendEmail(
owner.email,
html,
'BEZAHLUNG TROTZ ABSAGE',
)
const response = await sendEmail(owner.email, html, 'BEZAHLUNG TROTZ ABSAGE')

console.log(
`Message sent to: ${JSON.stringify(owner.email)}, Code : ${
response.statusCode
}`,
`Message sent to: ${JSON.stringify(owner.email)}, Code : ${response?.id}`,
)

return { success: response.statusCode === 201 }
return { success: response?.id }
}
6 changes: 2 additions & 4 deletions inngest/sendPaymentReminderEmail.tsx
Original file line number Diff line number Diff line change
@@ -25,16 +25,14 @@ export const sendPaymentReminderEmail = inngest.createFunction(

const html = render(<PaymentReminder event={event} userName={user.name} />)

const { response } = await sendEmail(
const response = await sendEmail(
user.email,
html,
'Erinnerung: Fussball bezahlen',
)

console.log(
`Message sent to: ${JSON.stringify(user.email)}, Code : ${
response.statusCode
}`,
`Message sent to: ${JSON.stringify(user.email)}, Code : ${response?.id}`,
)
},
)
4 changes: 2 additions & 2 deletions inngest/sendWelcomeMail.tsx
Original file line number Diff line number Diff line change
@@ -8,13 +8,13 @@ export const sendWelcomeMail = async (user: User | null) => {

if (!user?.email) return { success: false }

const { response } = await sendEmail(
const response = await sendEmail(
user.email,
html,
'Erfolgreich Registriert :)',
)

console.log(`Message sent to: ${JSON.stringify(user.email)}`)

return { success: response.statusCode === 201 }
return { success: response?.id }
}
9 changes: 1 addition & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@
},
"dependencies": {
"@google-cloud/local-auth": "2.1.1",
"@hookform/resolvers": "^3.1.1",
"@next-auth/prisma-adapter": "^1.0.7",
"@prisma/client": "^5.0.0",
"@radix-ui/react-accordion": "^1.1.2",
@@ -37,10 +36,6 @@
"@react-email/components": "^0.0.7",
"@react-email/tailwind": "0.0.8",
"@sendinblue/client": "^3.3.1",
"@tanstack/react-query": "^4.32.0",
"@tanstack/react-query-devtools": "^4.35.0",
"@types/lodash": "^4.14.195",
"@types/nodemailer": "^6.4.8",
"axios": "^1.3.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
@@ -67,7 +62,6 @@
"react-dom": "18.2.0",
"react-email": "1.9.4",
"react-hook-form": "^7.45.2",
"react-loading-skeleton": "^3.3.1",
"superjson": "^1.13.1",
"tailwind-merge": "^1.14.0",
"tailwindcss-animate": "^1.0.6",
@@ -99,6 +93,5 @@
"ts-node": "^10.9.1",
"tsx": "^3.12.7",
"typescript": "^5.1.6"
},
"packageManager": "yarn@3.5.0"
}
}
14 changes: 2 additions & 12 deletions src/emails/transporter.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
import {
TransactionalEmailsApi,
TransactionalEmailsApiApiKeys,
} from "@sendinblue/client";
import { Resend } from 'resend'

const apiInstance = new TransactionalEmailsApi();

apiInstance.setApiKey(
TransactionalEmailsApiApiKeys.apiKey,
process.env.SENDINBLUE_API_KEY ?? ""
);

export default apiInstance;
export const resend = new Resend(process.env.RESEND_API_KEY)