|
|
@@ -6,9 +6,11 @@ const { |
|
|
AMQP_EXCHANGE, |
|
|
AMQP_EXCHANGE, |
|
|
AMQP_QUEUE = "email-forwarder", |
|
|
AMQP_QUEUE = "email-forwarder", |
|
|
SMTP_HOST, |
|
|
SMTP_HOST, |
|
|
SMTP_PORT = "25", |
|
|
|
|
|
|
|
|
SMTP_PORT = "587", |
|
|
|
|
|
SMTP_USER, |
|
|
|
|
|
SMTP_PASSWORD, |
|
|
NOTIFY_TO, |
|
|
NOTIFY_TO, |
|
|
NOTIFY_FROM = "hal@novox.be", |
|
|
|
|
|
|
|
|
NOTIFY_FROM, |
|
|
} = process.env; |
|
|
} = process.env; |
|
|
|
|
|
|
|
|
async function main() { |
|
|
async function main() { |
|
|
@@ -20,15 +22,19 @@ async function main() { |
|
|
await ch.bindQueue(AMQP_QUEUE, AMQP_EXCHANGE, ""); |
|
|
await ch.bindQueue(AMQP_QUEUE, AMQP_EXCHANGE, ""); |
|
|
console.log(`Bound queue '${AMQP_QUEUE}' to exchange '${AMQP_EXCHANGE}'`); |
|
|
console.log(`Bound queue '${AMQP_QUEUE}' to exchange '${AMQP_EXCHANGE}'`); |
|
|
|
|
|
|
|
|
const transport = nodemailer.createTransport({ |
|
|
|
|
|
|
|
|
const transportOpts = { |
|
|
host: SMTP_HOST, |
|
|
host: SMTP_HOST, |
|
|
port: parseInt(SMTP_PORT), |
|
|
port: parseInt(SMTP_PORT), |
|
|
secure: false, |
|
|
secure: false, |
|
|
tls: { rejectUnauthorized: false }, |
|
|
tls: { rejectUnauthorized: false }, |
|
|
}); |
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
if (SMTP_USER && SMTP_PASSWORD) { |
|
|
|
|
|
transportOpts.auth = { user: SMTP_USER, pass: SMTP_PASSWORD }; |
|
|
|
|
|
} |
|
|
|
|
|
const transport = nodemailer.createTransport(transportOpts); |
|
|
|
|
|
|
|
|
console.log(`SMTP: ${SMTP_HOST}:${SMTP_PORT}`); |
|
|
|
|
|
console.log(`Forwarding to: ${NOTIFY_TO}`); |
|
|
|
|
|
|
|
|
console.log(`SMTP: ${SMTP_USER || "(no auth)"}@${SMTP_HOST}:${SMTP_PORT}`); |
|
|
|
|
|
console.log(`From: ${NOTIFY_FROM} → To: ${NOTIFY_TO}`); |
|
|
console.log("Waiting for messages...\n"); |
|
|
console.log("Waiting for messages...\n"); |
|
|
|
|
|
|
|
|
ch.consume(AMQP_QUEUE, async (msg) => { |
|
|
ch.consume(AMQP_QUEUE, async (msg) => { |
|
|
|