diff -upr mailx-12.5.orig/names.c mailx-12.5/names.c
--- mailx-12.5.orig/names.c	2006-03-04 01:32:16.000000000 +0100
+++ mailx-12.5/names.c	2012-11-01 15:28:43.883573793 +0100
@@ -357,7 +357,7 @@ outof(struct name *names, FILE *fo, stru
 			free_child(pid);
 		} else {
 			int f;
-			if ((fout = Zopen(fname, "a", NULL)) == NULL) {
+			if ((fname == NULL) || ((fout = Zopen(fname, "a", NULL)) == NULL)) {
 				perror(fname);
 				senderr++;
 				goto cant;
