Closed sjs7007 closed 8 years ago
curl :
curl -s --user 'api:key-' \
https://api.mailgun.net/v3/sandbox2796510b356d4fd5a02c639af3080887.mailgun.org/messages \
-F from='Excited User <postmaster@sandbox2796510b356d4fd5a02c639af3080887.mailgun.org>' \
-F to=sjs7007@gmail.com \
-F subject='Hello' \
-F text='Testing some Mailgun awesomness!'
nodejs using mailgunjs :
console.log("test")
var api_key = '';
var domain = 'sandbox2796510b356d4fd5a02c639af3080887.mailgun.org';
var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});
var data = {
from: 'Excited User <postmaster@sandbox2796510b356d4fd5a02c639af3080887.mailgun.org>',
to: 'sjs7007@gmail.com',
subject: 'Hello',
text: 'Testing some Mailgun awesomness!'
};
mailgun.messages().send(data, function (error, body) {
console.log(body);
});
Look into kafka :
From first looks seems to be a solution for dealing with live data
Not for user email but use it to create server dashboard tracking different types of jobs going on, loads on server etc maybe.
make email better : send html form along with update to do things like pause, resume, suspend
var domain = 'mydomain.mailgun.org';
var mailgun = require('mailgun-js')({ apiKey: "YOUR API KEY", domain: domain });
var mailcomposer = require('mailcomposer');
var mail = mailcomposer({
from: 'you@samples.mailgun.org',
to: 'mm@samples.mailgun.org',
subject: 'Test email subject',
body: 'Test email text',
html: '<b> Test email text </b>'
});
mail.build(function(mailBuildError, message) {
var dataToSend = {
to: 'mm@samples.mailgun.org',
message: message.toString('ascii')
};
mailgun.messages().sendMime(dataToSend, function (sendError, body) {
if (sendError) {
console.log(sendError);
return;
}
});
});
Send html forms with prefilled data and hidden fields for pausing, resuming and killing.
intput type="hidden" will hide that field
use ejs for dynamic html +
for saving in text form to send
ejs code
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
</head>
<body>
<h1>S3-Lab-Test</h1>
<form action="http://localhost:8888/killProcess" enctype="multipart/form-data" method="post">
Process ID : <input type="hidden" name="pid" value= <%= pid %> > <br>
<input type="submit" value="kill process" />
</form>
</body>
</html>
express code for rendering
var express = require('express');
var app = express();
app.set('view engine', 'ejs');
app.get('/', function(req, res){
res.render('killProcess.ejs',{pid: "203"});
});
app.listen(8888,function() {
console.log('App listen 8888');
});
ejs code for rendering and sending mail
var domain = 'sandbox2796510b356d4fd5a02c639af3080887.mailgun.org';
var mailgun = require('mailgun-js')({ apiKey: "dummy", domain: domain });
var mailcomposer = require('mailcomposer');
var ejs = require('ejs');
var sendMail = function(data) {
var mail = mailcomposer({
from: 'S3 Lab <postmaster@sandbox2796510b356d4fd5a02c639af3080887.mailgun.org>',
to: 'sjs7007@gmail.com',
subject: 'Test email subject',
body: 'Test email text',
html: data
});
mail.build(function(mailBuildError, message) {
var dataToSend = {
to: 'sjs7007@gmail.com',
message: message.toString('ascii')
};
mailgun.messages().sendMime(dataToSend, function (sendError, body) {
if (sendError) {
console.log(sendError);
return;
}
});
});
}
var fs = require('fs');
fs.readFile('./killProcess.ejs',function(err,ejsTemplate) {
if(err) {
console.log(err);
}
else {
ejsTemplate = ejsTemplate.toString();
console.log(ejsTemplate);
htmlGen = ejs.render(ejsTemplate,{pid: "405"});
sendMail(htmlGen);
}
});
Added all buttons. Gmail on android doesn't allow forms.
https://productforums.google.com/forum/#!topic/docs/MrDT69owdGk
Send email updates to user whenever status changes.
Options : Gmail / email service like mailgun gmail, harder to setup, can lead to captcha
using mailgun for now : https://mailgun.com/app/dashboard