.Xc
Path to the local aliases file.
Just stick with the default.
+The aliases file is of the format
+.Dl nam: dest1 dest2 ...
+In this case, mails to
+.Li nam
+will instead be delivered to
+.Li dest1
+and
+.Li dest2 ,
+which in turn could be entries in
+.Pa /etc/aliases .
+The special name
+.Ql *
+can be used to create a catch-all alias, which gets used if no other
+matching alias is found.
+Use the catch-all alias only if you don't want any local mail to be
+delivered.
.It Ic SPOOLDIR Xo
(string, default=/var/spool/dma)
.Xc
return (0);
}
+static int
+do_alias(struct queue *queue, const char *addr)
+{
+ struct alias *al;
+ struct stritem *sit;
+ int aliased = 0;
+
+ LIST_FOREACH(al, &aliases, next) {
+ if (strcmp(al->alias, addr) != 0)
+ continue;
+ SLIST_FOREACH(sit, &al->dests, next) {
+ if (add_recp(queue, sit->str, EXPAND_ADDR) != 0)
+ return (-1);
+ }
+ aliased = 1;
+ }
+
+ return (aliased);
+}
+
int
add_recp(struct queue *queue, const char *str, int expand)
{
struct qitem *it, *tit;
- struct stritem *sit;
- struct alias *al;
struct passwd *pw;
char *host;
int aliased = 0;
if (strrchr(it->addr, '@') == NULL) {
it->remote = 0;
if (expand) {
- LIST_FOREACH(al, &aliases, next) {
- if (strcmp(al->alias, it->addr) != 0)
- continue;
- SLIST_FOREACH(sit, &al->dests, next) {
- if (add_recp(queue, sit->str, 1) != 0)
- return (-1);
- }
- aliased = 1;
- }
+ aliased = do_alias(queue, it->addr);
+ if (!aliased && expand == EXPAND_WILDCARD)
+ aliased = do_alias(queue, "*");
+ if (aliased < 0)
+ return (-1);
if (aliased) {
LIST_REMOVE(it, next);
} else {
setlogident("%s", queue.id);
for (i = 0; i < argc; i++) {
- if (add_recp(&queue, argv[i], 1) != 0)
+ if (add_recp(&queue, argv[i], EXPAND_WILDCARD) != 0)
errlogx(1, "invalid recipient `%s'", argv[i]);
}
int base64_decode(const char *, void *);
/* dma.c */
+#define EXPAND_ADDR 1
+#define EXPAND_WILDCARD 2
int add_recp(struct queue *, const char *, int);
void run_queue(struct queue *);
bzero(&bounceq, sizeof(bounceq));
LIST_INIT(&bounceq.queue);
bounceq.sender = "";
- if (add_recp(&bounceq, it->sender, 1) != 0)
+ if (add_recp(&bounceq, it->sender, EXPAND_WILDCARD) != 0)
goto fail;
if (newspoolf(&bounceq) != 0)
if (addr == NULL)
errlog(1, NULL);
- if (add_recp(queue, addr, 1) != 0)
+ if (add_recp(queue, addr, EXPAND_WILDCARD) != 0)
errlogx(1, "invalid recipient `%s'", addr);
goto again;