summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-03-01 22:19:02 +0100
committerTom Smeding <tom@tomsmeding.com>2024-03-01 22:19:02 +0100
commit1bab845f16d2fc6e07ea97a9a59e21d6a8390ff7 (patch)
treea5d08dcecd26b19a6aba2d2989d8e552ace88b32
parenta246f40d5de04c1c7fcc7385d36bc593bcee6ce6 (diff)
sendmail -> msmtp
-rw-r--r--modules/changes/changes.js11
-rw-r--r--modules/email/email.js7
2 files changed, 8 insertions, 10 deletions
diff --git a/modules/changes/changes.js b/modules/changes/changes.js
index dbfe55c..0d8fa24 100644
--- a/modules/changes/changes.js
+++ b/modules/changes/changes.js
@@ -222,19 +222,19 @@ function sendMail(tomails,body,cb){
}
var proc;
for(i=0;i<tomails.length;i++){
- proc=child_process.spawn("sendmail",[tomails[i]],{stdio:["pipe",process.stdout,process.stderr]});
+ proc=child_process.spawn("msmtp",["--read-recipients"],{stdio:["pipe",process.stdout,process.stderr]});
proccounter++;
- console.log("sendmail process for <"+tomails[i]+"> started");
+ console.log("msmtp process for <"+tomails[i]+"> started");
proc.stdin.on("error",function(e){
console.log(e);
cb(e);
});
proc.stdin.write("To: "+tomails[i]+"\n"+body,function(proc,mailtarget){
- console.log("sendmail process for <"+mailtarget+"> write completed");
+ console.log("msmtp process for <"+mailtarget+"> write completed");
proc.stdin.end();
}.bind(this,proc,tomails[i]));
proc.on("exit",function(mailtarget,code,signal){
- console.log("sendmail process for <"+mailtarget+"> exited with code "+code);
+ console.log("msmtp process for <"+mailtarget+"> exited with code "+code);
decProcCounter();
}.bind(this,tomails[i]));
//process will linger till it's finished
@@ -242,8 +242,7 @@ function sendMail(tomails,body,cb){
}
function constructMailBody(diffs){
- var body="From: changes <changes_module@tomsmeding.com>\n"+
- "Subject: changes notification mail\n\n"+
+ var body="Subject: changes notification mail\n\n"+
"The changes module recorded some changes in watched webpages.\n"+
"The URLs and their old and new content hashes are shown below.\n\n";
var i;
diff --git a/modules/email/email.js b/modules/email/email.js
index 15a35f5..e4d342b 100644
--- a/modules/email/email.js
+++ b/modules/email/email.js
@@ -20,21 +20,20 @@ function sendEmail(recip, text) {
var opts = {
stdio: ["pipe", "inherit", "inherit"]
};
- var proc = child_process.spawn("sendmail", [recip], opts);
+ var proc = child_process.spawn("msmtp", ["--read-recipients"], opts);
// Make sure it doesn't run indefinitely
var timeout = setTimeout(() => {proc.kill();}, 5000);
proc.on("exit", () => clearTimeout(timeout));
proc.on("error", err => {
- console.log("email: Failed to start sendmail:", err);
+ console.log("email: Failed to start msmtp:", err);
clearTimeout(timeout);
});
proc.stdin.on("error", err => {
- console.log("email: Failed to write to sendmail:", err);
+ console.log("email: Failed to write to msmtp:", err);
clearTimeout(timeout);
});
proc.stdin.end(
- "From: email-module@tomsmeding.com\n" +
"To: " + recip + "\n" +
"Subject: Mail from email module\n\n" +
text