Allow the envelope sender for emails to be configured,
authorTom Hughes <tom@compton.nu>
Tue, 22 Sep 2009 23:38:42 +0000 (23:38 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 22 Sep 2009 23:38:42 +0000 (23:38 +0000)
settings.sh
src/interpolate.c

index e365434..1fbf6d9 100755 (executable)
@@ -36,6 +36,9 @@ setting LOG_FILE /home/osm/gpx-import.log
 # If you comment out the PIDFILE then it will not daemonise
 setting PID_FILE /home/osm/gpx-import.pid
 
+# Mail notifications
+#setting MAIL_SENDER example@example.com
+
 # Optional debug statements
 #setting INTERPOLATE_STDOUT 1
 
index 716f9d8..b49c483 100644 (file)
@@ -100,7 +100,13 @@ interpolate(DBJob *job, const char *template)
   if (getenv("GPX_INTERPOLATE_STDOUT") != NULL) {
     outputfile = stdout;
   } else {
-    outputfile = popen("/usr/lib/sendmail -t -r '<>'", "w");
+    const char *sender;
+    char command[256];
+    if ((sender = getenv("MAIL_SENDER")) == NULL) {
+       sender = "";
+    }
+    snprintf(command, sizeof(command), "/usr/lib/sendmail -t -r '<%s>'", sender);
+    outputfile = popen(command, "w");
     if (outputfile == NULL) {
       ERROR("Unable to open sendmail! (errno=%s)", strerror(errno));
       return;