config.certfile = data;
else if (strcmp(word, "MAILNAME") == 0 && data != NULL)
config.mailname = data;
- else if (strcmp(word, "STARTTLS") == 0 && data == NULL)
+ else if (strcmp(word, "MASQUERADE") == 0 && data != NULL) {
+ char *user = NULL, *host = NULL;
+ if (strrchr(data, '@')) {
+ host = strrchr(data, '@');
+ host = 0;
+ host++;
+ user = data;
+ } else {
+ host = data;
+ }
+ if (host && *host == 0)
+ host = NULL;
+ if (user && *user == 0)
+ user = NULL;
+ config.masquerade_host = host;
+ config.masquerade_user = user;
+ } else if (strcmp(word, "STARTTLS") == 0 && data == NULL)
config.features |= STARTTLS;
else if (strcmp(word, "OPPORTUNISTIC_TLS") == 0 && data == NULL)
config.features |= TLS_OPP;
.Sq MAILNAME
is an absolute path to a file, the first line of this file will be used
as the hostname.
+.It Ic MASQUERADE Xo
+(string, default=empty)
+.Xc
+Masquerade the envelope from addresses with this address/hostname.
+Use this setting if mails are not accepted by destination mail servers
+because your sender domain is invalid.
+This setting is overridden by the
+.Fl f
+flag and the
+.Ev EMAIL
+environment variable.
+.Pp
+If
+.Sq MASQUERADE
+does not contain a
+.Li @
+sign, the string is interpreted as a host name.
+For example, setting
+.Sq MASQUERADE
+to
+.Ql john@
+on host
+.Ql hamlet
+will send all mails as
+.Ql john@hamlet ;
+setting it to
+.Ql percolator
+will send all mails as
+.Ql Sm off Va username @percolator .
+.Sm on
.El
.Ss Environment variables
The behavior of
.certfile = NULL,
.features = 0,
.mailname = NULL,
+ .masquerade_host = NULL,
+ .masquerade_user = NULL,
};
if (sender == NULL)
return (NULL);
} else {
- if (asprintf(&sender, "%s@%s", username, hostname()) <= 0)
+ const char *from_user = username;
+ const char *from_host = hostname();
+
+ if (config.masquerade_user)
+ from_user = config.masquerade_user;
+ if (config.masquerade_host)
+ from_host = config.masquerade_host;
+ if (asprintf(&sender, "%s@%s", from_user, from_host) <= 0)
return (NULL);
}
# If MAILNAME is an absolute path to a file, the first line of this file
# will be used as the hostname.
#MAILNAME mail.example.net
+
+# Masquerade envelope from addresses with this address/hostname.
+# Use this if mails are not accepted by destination mail servers because
+# your sender domain is invalid.
+# By default, MASQUERADE is not set.
+# Format: MASQUERADE [user@][host]
+# Examples:
+# MASQUERADE john@ on host "hamlet" will send all mails as john@hamlet
+# MASQUERADE percolator will send mails as $username@percolator, e.g. fish@percolator
+# MASQUERADE herb@ert will send all mails as herb@ert
const char *certfile;
int features;
const char *mailname;
+ const char *masquerade_host;
+ const char *masquerade_user;
/* XXX does not belong into config */
SSL *ssl;