Merge branch 'dev' of https://git.hanasys.jp/qcast3/onsitesurvey into feature/survey
This commit is contained in:
commit
23164a3f8c
@ -16,4 +16,11 @@ DB_HOST=202.218.61.226
|
|||||||
DB_USER=readonly
|
DB_USER=readonly
|
||||||
DB_PASSWORD=aAjmFW12iHKW84l1
|
DB_PASSWORD=aAjmFW12iHKW84l1
|
||||||
DB_DATABASE=qpartners
|
DB_DATABASE=qpartners
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
|
|
||||||
|
SMTP_HOST=autodiscover.qcells.com
|
||||||
|
SMTP_PORT=25
|
||||||
|
SMTP_SECURE=true
|
||||||
|
SMTP_USER=hss404.u021@cleverse.dev
|
||||||
|
SMTP_PASSWORD=0000
|
||||||
|
SMTP_FROM=qsalesplatform@qcells.com
|
||||||
@ -16,4 +16,11 @@ DB_HOST=202.218.61.226
|
|||||||
DB_USER=readonly
|
DB_USER=readonly
|
||||||
DB_PASSWORD=aAjmFW12iHKW84l1
|
DB_PASSWORD=aAjmFW12iHKW84l1
|
||||||
DB_DATABASE=qpartners
|
DB_DATABASE=qpartners
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
|
|
||||||
|
SMTP_HOST=autodiscover.qcells.com
|
||||||
|
SMTP_PORT=25
|
||||||
|
SMTP_SECURE=true
|
||||||
|
SMTP_USER=hss404.u021@cleverse.dev
|
||||||
|
SMTP_PASSWORD=0000
|
||||||
|
SMTP_FROM=qsalesplatform@qcells.com
|
||||||
|
|||||||
@ -14,4 +14,11 @@ DB_HOST=202.218.61.226
|
|||||||
DB_USER=readonly
|
DB_USER=readonly
|
||||||
DB_PASSWORD=aAjmFW12iHKW84l1
|
DB_PASSWORD=aAjmFW12iHKW84l1
|
||||||
DB_DATABASE=qpartners
|
DB_DATABASE=qpartners
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
|
|
||||||
|
SMTP_HOST=autodiscover.qcells.com
|
||||||
|
SMTP_PORT=25
|
||||||
|
SMTP_SECURE=true
|
||||||
|
SMTP_USER=hss404.u021@cleverse.dev
|
||||||
|
SMTP_PASSWORD=0000
|
||||||
|
SMTP_FROM=qsalesplatform@qcells.com
|
||||||
10
package-lock.json
generated
10
package-lock.json
generated
@ -18,6 +18,7 @@
|
|||||||
"mssql": "^11.0.1",
|
"mssql": "^11.0.1",
|
||||||
"mysql2": "^3.14.1",
|
"mysql2": "^3.14.1",
|
||||||
"next": "15.2.4",
|
"next": "15.2.4",
|
||||||
|
"nodemailer": "^7.0.3",
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
"react-dom": "^19.0.0",
|
"react-dom": "^19.0.0",
|
||||||
"react-to-pdf": "^2.0.0",
|
"react-to-pdf": "^2.0.0",
|
||||||
@ -3700,6 +3701,15 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
|
"node_modules/nodemailer": {
|
||||||
|
"version": "7.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-7.0.3.tgz",
|
||||||
|
"integrity": "sha512-Ajq6Sz1x7cIK3pN6KesGTah+1gnwMnx5gKl3piQlQQE/PwyJ4Mbc8is2psWYxK3RJTVeqsDaCv8ZzXLCDHMTZw==",
|
||||||
|
"license": "MIT-0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/open": {
|
"node_modules/open": {
|
||||||
"version": "10.1.0",
|
"version": "10.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/open/-/open-10.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/open/-/open-10.1.0.tgz",
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
"@prisma/client": "^6.7.0",
|
"@prisma/client": "^6.7.0",
|
||||||
"@tanstack/react-query": "^5.71.0",
|
"@tanstack/react-query": "^5.71.0",
|
||||||
"@tanstack/react-query-devtools": "^5.71.0",
|
"@tanstack/react-query-devtools": "^5.71.0",
|
||||||
|
"@types/nodemailer": "^6.4.17",
|
||||||
"axios": "^1.8.4",
|
"axios": "^1.8.4",
|
||||||
"env-cmd": "^10.1.0",
|
"env-cmd": "^10.1.0",
|
||||||
"iron-session": "^8.0.4",
|
"iron-session": "^8.0.4",
|
||||||
@ -25,6 +26,7 @@
|
|||||||
"mssql": "^11.0.1",
|
"mssql": "^11.0.1",
|
||||||
"mysql2": "^3.14.1",
|
"mysql2": "^3.14.1",
|
||||||
"next": "15.2.4",
|
"next": "15.2.4",
|
||||||
|
"nodemailer": "^7.0.3",
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
"react-dom": "^19.0.0",
|
"react-dom": "^19.0.0",
|
||||||
"react-to-pdf": "^2.0.0",
|
"react-to-pdf": "^2.0.0",
|
||||||
|
|||||||
47
src/libs/mailer.ts
Normal file
47
src/libs/mailer.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import nodemailer from 'nodemailer'
|
||||||
|
|
||||||
|
interface EmailParams {
|
||||||
|
to: string | string[]
|
||||||
|
cc?: string | string[]
|
||||||
|
subject: string
|
||||||
|
content: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function sendEmail({ to, cc, subject, content }: EmailParams): Promise<void> {
|
||||||
|
// Create a transporter using SMTP
|
||||||
|
const transporter = nodemailer.createTransport({
|
||||||
|
host: process.env.SMTP_HOST,
|
||||||
|
port: Number(process.env.SMTP_PORT),
|
||||||
|
secure: process.env.SMTP_SECURE === 'true',
|
||||||
|
auth: {
|
||||||
|
user: process.env.SMTP_USER,
|
||||||
|
pass: process.env.SMTP_PASSWORD,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
// Email options
|
||||||
|
const mailOptions = {
|
||||||
|
from: process.env.SMTP_USER,
|
||||||
|
to: Array.isArray(to) ? to.join(', ') : to,
|
||||||
|
cc: cc ? (Array.isArray(cc) ? cc.join(', ') : cc) : undefined,
|
||||||
|
subject,
|
||||||
|
html: content,
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Send email
|
||||||
|
await transporter.sendMail(mailOptions)
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error sending email:', error)
|
||||||
|
throw new Error('Failed to send email')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sendEmailTest() {
|
||||||
|
await sendEmail({
|
||||||
|
to: 'test@test.com',
|
||||||
|
cc: 'test2@test.com',
|
||||||
|
subject: 'Test Email',
|
||||||
|
content: '<h1>Hello</h1><p>This is a test email.</p>',
|
||||||
|
})
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user