66 lines
1.9 KiB
JavaScript
66 lines
1.9 KiB
JavaScript
|
import Mailjet from 'node-mailjet';
|
||
|
|
||
|
export default defineEventHandler(async (event) => {
|
||
|
|
||
|
const body = await readBody(event);
|
||
|
|
||
|
// const mailjet = new Mailjet({
|
||
|
// apiKey: useRuntimeConfig().mailjetApiPublic,
|
||
|
// apiSecret: useRuntimeConfig().mailjetApiPrivate
|
||
|
// });
|
||
|
|
||
|
// const request = mailjet
|
||
|
// .post('send', { version: 'v3.1' })
|
||
|
// .request({
|
||
|
// Messages: [
|
||
|
// {
|
||
|
// From: {
|
||
|
// Email: 'contact@paulnicoue.com',
|
||
|
// Name: body.name,
|
||
|
// },
|
||
|
// To: [
|
||
|
// {
|
||
|
// Email: 'contact@paulnicoue.com',
|
||
|
// Name: 'Paul Nicoué',
|
||
|
// },
|
||
|
// ],
|
||
|
// Subject: body.subject,
|
||
|
// TextPart: body.message
|
||
|
// }
|
||
|
// ]
|
||
|
// });
|
||
|
|
||
|
// request
|
||
|
// .then(result => {console.log(result.body)})
|
||
|
// .catch(err => {console.log(err.statusCode)});
|
||
|
|
||
|
Mailjet
|
||
|
.apiConnect(
|
||
|
useRuntimeConfig().mailjetApiPublic,
|
||
|
useRuntimeConfig().mailjetApiPrivate
|
||
|
)
|
||
|
.post('send', { version: 'v3.1' })
|
||
|
.request({
|
||
|
Messages: [
|
||
|
{
|
||
|
From: {
|
||
|
Email: 'contact@paulnicoue.com',
|
||
|
Name: body.name,
|
||
|
},
|
||
|
To: [
|
||
|
{
|
||
|
Email: 'contact@paulnicoue.com',
|
||
|
Name: 'Paul Nicoué',
|
||
|
},
|
||
|
],
|
||
|
Subject: body.subject,
|
||
|
TextPart: body.message
|
||
|
}
|
||
|
]
|
||
|
})
|
||
|
.then((result) => console.log(result.body))
|
||
|
.catch((err) => console.log(err.statusCode));
|
||
|
|
||
|
return event.node.res.end();
|
||
|
});
|