Browse Source

dynamic email sending

master
mikeyangelo5 2 years ago
parent
commit
c4fc978e5a
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      index.mjs

+ 2
- 2
index.mjs View File

@@ -38,7 +38,7 @@ amqp.connect('amqp://localhost' ).then(async conn=> {
return ch.consume(queueName, async (msg) => { return ch.consume(queueName, async (msg) => {
var messageBody = JSON.parse(msg.content.toString()) var messageBody = JSON.parse(msg.content.toString())
console.log(`[*] Message Received! email : ${messageBody.email} and pesan : ${messageBody.html}`) console.log(`[*] Message Received! email : ${messageBody.email} and pesan : ${messageBody.html}`)
// sendReceipt("michael.pandu270@gmail.com", "Berikut detail nota terbaru anda")
sendReceipt(messageBody.email, messageBody.html)
}, { noAck: true }) }, { noAck: true })
}).then(() => { }).then(() => {
console.log('* Waiting for messages from queue ' + queueName) console.log('* Waiting for messages from queue ' + queueName)
@@ -53,7 +53,7 @@ function sendReceipt(recepientEmail, receipt) {
to: [{email: recepientEmail, name: 'Customer'}], to: [{email: recepientEmail, name: 'Customer'}],
subject: "test", subject: "test",
textContent: "testing", textContent: "testing",
htmlContent: "<h1>test</h1>"
htmlContent: receipt
} }
apiInstance.sendTransacEmail(sendSmtpEmail).then(function(data) { apiInstance.sendTransacEmail(sendSmtpEmail).then(function(data) {
console.log('API called successfully. Returned data: ' + data) console.log('API called successfully. Returned data: ' + data)


Loading…
Cancel
Save