|
1 | 1 | import { NextRequest, NextResponse } from "next/server"; |
2 | 2 | import prisma from "@/database/db"; |
3 | 3 | import nodemailer from "nodemailer"; |
| 4 | +import path from "path"; |
4 | 5 |
|
5 | 6 | export async function POST(req: NextRequest) { |
6 | 7 | try { |
@@ -77,13 +78,14 @@ const transport = nodemailer.createTransport({ |
77 | 78 |
|
78 | 79 | async function sendEmail(prospects: any, ref: any, member: any) { |
79 | 80 | let emailsSent = true; |
| 81 | + const emailImgPath = path.join(process.cwd(), "public", "assets", "paso-coop.jpeg"); |
| 82 | + |
80 | 83 | for (const prospect of prospects) { |
81 | 84 | // console.log(prospect.prospect_email); |
82 | 85 | const mail = { |
83 | 86 | from: process.env.FROM_EMAIL, |
84 | 87 | to: prospect.prospect_email, |
85 | 88 | subject: "You've Been Invited!", |
86 | | - text: `Hello! -nodemailer\n`, |
87 | 89 | html: `<div style="width: 100%; max-width: 600px; margin: 0 auto; font-family: Arial, sans-serif; line-height: 1.6; color: #333;"> |
88 | 90 | |
89 | 91 | |
@@ -134,7 +136,7 @@ async function sendEmail(prospects: any, ref: any, member: any) { |
134 | 136 | attachments: [ |
135 | 137 | { |
136 | 138 | filename: "paso-coop.jpeg", // Name of the file as it will appear in the email |
137 | | - path: "public/assets/paso-coop.jpeg", // Path relative to your project root |
| 139 | + path: emailImgPath, // Path relative to your project root |
138 | 140 | cid: "pasoLogo", // Content ID referenced in the HTML img src |
139 | 141 | }, |
140 | 142 | ], |
|
0 commit comments