Invite members (#161)
* Allow user invitations * Restyle inviting members * Remove annoying comment * Add page for accepting an invitation * Send invitation email with Brevo * Prevent admins from removing personal project users * Mark access ceontrol for cancelProjectInvitation * Make RadioGroup controlled * Shorten form helper text * Use nodemailer to send emails * Update .env.example
This commit is contained in:
31
app/src/server/emails/sendEmail.ts
Normal file
31
app/src/server/emails/sendEmail.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { marked } from "marked";
|
||||
import nodemailer from "nodemailer";
|
||||
import { env } from "~/env.mjs";
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
// All the SMTP_ env vars come from https://app.brevo.com/settings/keys/smtp
|
||||
// @ts-expect-error nodemailer types are wrong
|
||||
host: env.SMTP_HOST,
|
||||
port: env.SMTP_PORT,
|
||||
auth: {
|
||||
user: env.SMTP_LOGIN,
|
||||
pass: env.SMTP_PASSWORD,
|
||||
},
|
||||
});
|
||||
|
||||
export const sendEmail = async (options: { to: string; subject: string; body: string }) => {
|
||||
const bodyHtml = await marked.parseInline(options.body, { mangle: false });
|
||||
|
||||
try {
|
||||
await transporter.sendMail({
|
||||
from: env.SENDER_EMAIL,
|
||||
to: options.to,
|
||||
subject: options.subject,
|
||||
html: bodyHtml,
|
||||
text: options.body,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("error sending email", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user