log every step
Signed-off-by: Ferit Yiğit BALABAN <fyb@fybx.dev>
This commit is contained in:
parent
0d45dc28a3
commit
c8863a09b5
10
index.js
10
index.js
@ -50,7 +50,6 @@ const transporter = nodemailer.createTransport({
|
|||||||
app.post('/api/mail', (req, res) => {
|
app.post('/api/mail', (req, res) => {
|
||||||
const { to, subject, text } = req.body;
|
const { to, subject, text } = req.body;
|
||||||
|
|
||||||
let status = false;
|
|
||||||
const mail = {
|
const mail = {
|
||||||
from: `"Arbeit Mail Hizmeti" <${SENDER_EMAIL}>`,
|
from: `"Arbeit Mail Hizmeti" <${SENDER_EMAIL}>`,
|
||||||
to,
|
to,
|
||||||
@ -60,8 +59,13 @@ app.post('/api/mail', (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (ENV === 'PROD') {
|
if (ENV === 'PROD') {
|
||||||
if (transporter.sendMail(mail)) res.status(200).json({ message: 'Mail sent successfully!' });
|
if (transporter.sendMail(mail)) {
|
||||||
else res.status(500).json({ message: 'Mail could not be sent!' });
|
console.info('Sent something:', mail);
|
||||||
|
res.status(200).json({ message: 'Mail sent successfully!' });
|
||||||
|
} else {
|
||||||
|
console.error('Failed to send:', mail);
|
||||||
|
res.status(500).json({ message: 'Mail could not be sent!' });
|
||||||
|
};
|
||||||
} else res.status(200).json(mail);
|
} else res.status(200).json(mail);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user