Skip to content

Instantly share code, notes, and snippets.

@tonis2
Created June 25, 2018 11:36
Show Gist options
  • Save tonis2/7639afe88a6b27ca4eca5223797e70b5 to your computer and use it in GitHub Desktop.
Save tonis2/7639afe88a6b27ca4eca5223797e70b5 to your computer and use it in GitHub Desktop.
Send mail with node.js and ssmtp
const emails = "[email protected]"
const msg = `<p><span>msg:${req.body.msg}</span> <br /> <span>url:${req.body.url}</span> <br /> <span>line:${req.body.lineNo}</span> <br /> <span>column:${req.body.columnNo}</span> <br /> error:${req.body.error}</p>`;
exec.exec(`echo "From:[email protected]\r\nDate: $(date)\r\nSubject:website crash report\r\nMIME-Version: 1.0\r\nContent-Type: text/html; charset=utf-8\r\n\r\n ${msg}" | sudo ssmtp -vvv -C ssmpt2.conf -ap 55604881 -F " Pro error" ${emails}`, (err, stdout, stderr) => {
if (err) {return;}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment