
| Current Path : /proc/thread-self/root/home/jstimm/Desktop/50_dev2017/1313__procpyjs/test/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : //proc/thread-self/root/home/jstimm/Desktop/50_dev2017/1313__procpyjs/test/email.js |
var kue = require('kue');
var Mailgun = require('mailgun-js');
var api_key = 'key-9bab02f84a92801800096e882ab69035';
var domain = 'sandbox6f2534dedef141a4a317197ac16e03f1.mailgun.org';
var mailgun = new Mailgun({
apiKey: api_key,
domain: domain
});
var jobs = kue.createQueue();
var minute = 60000;
var email = jobs.create('email', {
title: 'Account renewal required',
to: 'stschwarz@ift-informatik.de',
from: 'procpymailer@ift-informatik.de',
subject: 'renewal-email',
html: 'Hello,<br><br>please <b>renew</b> your email address!<br>You have 10 minutes to fulfill this renewal request, otherwise we will expire your account.<br><br>Yours sincerely.'
}).delay(minute)
.priority('high')
.save();
email.on('promotion', function() {
console.log('renewal job promoted');
});
email.on('complete', function() {
console.log('renewal job completed');
});
jobs.create('email', {
title: 'Account expired',
to: 'stschwarz@ift-informatik.de',
from: 'procpymailer@ift-informatik.de',
subject: 'Account expired',
html: 'Hello,<br><br>your account is <b>expired</b>.'
}).delay(minute * 10)
.priority('high')
.save();
//jobs.promote();
jobs.process('email', 10, function(job, done) {
setTimeout(function() {
mailgun.messages().send(job.data, function(err, body) {
console.log(err || body);
});
done();
}, Math.random() * 5000);
});
// start the UI
kue.app.listen(3030);
console.log('UI started on port 3030');