From c710dddfc4f80119fa13453ae6bc8df51a98f68a Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Tue, 21 Jan 2020 07:27:35 +0000
Subject: [PATCH] Fix bug introduced in previous commit as reported by Nelgin:
 to and from extension header fields were being set (for the mail base) even
 when the to or from name was not a valid local user name (thus an extension
 value of "0" was being stored in the header) - causing netmail imported with
 postmsg.js to never get exported.

---
 exec/postmsg.js | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/exec/postmsg.js b/exec/postmsg.js
index 1c69307554..9651a728b2 100644
--- a/exec/postmsg.js
+++ b/exec/postmsg.js
@@ -124,10 +124,11 @@ if(!hdrs.from)
 	hdrs.from = prompt("From User name");
 if(!hdrs.subject)
 	hdrs.subject = prompt("Subject");
-if(!hdrs.to_ext && sub_code == 'mail')
-	hdrs.to_ext = system.matchuser(hdrs.to);
-if(!hdrs.from_ext)
-	hdrs.from_ext = system.matchuser(hdrs.from);
+var num;
+if(!hdrs.to_ext && sub_code == 'mail' && (num = system.matchuser(hdrs.to)) != 0)
+	hdrs.to_ext = num;
+if(!hdrs.from_ext && (num = system.matchuser(hdrs.from)) != 0)
+	hdrs.from_ext = num;
 if(!msgbase.save_msg(hdrs, body)) {
 	alert("Error saving message: " + msgbase.last_error);
 	exit();
-- 
GitLab