Fetch emails from a catch-all mailbox and deliver them to different NS8 users/mailboxes

NethServer Version: 8

I’ve installed Nethserver 8 as an internal server in the local network.

Multiple users have been created and also some public mailboxes.

Is there any way to periodically fetch emails from a (remote) catch-all mailbox (remote mail server, e.g. *@example.com) and deliver them to the local users (and local public mailboxes)?
Maybe with a default user/mailbox for emails that can’t be matched/delivered?

I did not find anything in the documentation or configuration.

There was some discussion years ago (NS7) regarding this, see

Unfortunately imapsync has no option to filter recipient addresses but fetchmail could do the job, see also Fetchmail Manual.

1 Like

Is a sieve filter an alternative? For example a special account with Sieve rules distributing messages fetched by Impasync from the multi drop remote account…

2 Likes

Yes, sieve filters do work here too.

A special user “fetchinguser” was created and is used in Imapsync as destination for mails fetched from a multidrop catchall maillbox on another server. The sieve processing is enabled in the imapsync task due to fetching “only inbox”, see also Use Imapsync to sync mail to a public mailbox? - #4 by mrmarkuz and Imapsync — NS8 documentation

In Roundcube I created sieve filters for the users, here for example for user Markus:

…and here is another example for user Buck:

This way you can add a sieve filter per user that should get mails from the multidrop mailbox.

You can check the mailbox of the fetchinguser from time to time for mails that couldn’t be processed by the sieve filters.

EDIT:

Please check the known limitations of the imapsync implementation.

1 Like

Thanks for providing this solution! I’m gonna test it. One follow-up question: Are the filters also executed when Roundcube is not open (on the server)?

And: is there any way to get around the mentioned limitations (spam check/virus check/auto reply)?

I tested with fetchmail and also got it running.

set postmaster "info@example.com"
set no bouncemail
set no spambounce

poll pop.remoteserver.com tracepolls proto pop3 uidl auth password port 995 timeout 60
    localdomains "example.com" user "*@example.com" password "<PASSWORD>" ssl keep to *

All emails are delivered to existing users and mailboxes. If a user doesn’t exist (e.g. not.existing.user@example.com), the mail is delivered to the postmaster (in this case specified as: info@example.com)

But with the downsides

  • it’s not manageable in the UI (but doesn’t need to be touched when a new user is added)
  • I’m not sure, but I think the same limitations (virus/spam/auto-reply) apply
1 Like

Yes and you could also use SOGo or WebTop for creating the filters instead of Roundcube.

No, except configuring it on the remote server if possible.

No, fetchmail sends the mails via SMTP so the virus/spam filters should work.
I think also auto-reply works.

1 Like

@mrmarkuz I also saw your ns-8fetchmail implementation, but can’t get it running (the cronjob doesn’t start, maybe there’s some additional configuration needed?).
Is this still maintained?

It should work AFAIK but I’m going to check…

I neglected it but If there are updates I’m going to release a new version.

1 Like

I set up a auto-reply filter. The filter works if I send an email internally, but not when I use fetchmail for delivering the email from the remote server.
Any idea why the auto reply email is not sent? Where or how can I check why this doesn’t work?

You could check the logs of the mail app to maybe find infos why the mail isn’t sent. The issue could be that the autoreply is just sent once per sender.

Ok, the system log says that the vacation response has been sent, but I don’t receive it.

This is the vacation response to the internal user (which is received); the initial email has been sent from second.user@example.com to first.user@example.com

Dec 01 18:11:42 zeus2 dovecot[1001644]: lmtp(first.user)<9327><2a80Bk7MLWlvJAAAt2YSYA>: sieve: msgid=<5327709799a5f5efa31849832860ca9d@example.com>: vacation action: sent vacation response to <second.user@example.com>

And this is the vacation response to the external user (which is not received); the initial email has been sent from someexternal.user@external.net to first.user@example.com

Dec 01 18:13:43 zeus2 dovecot[1001644]: lmtp(first.user)<9392><sCIDDMfMLWmwJAAAt2YSYA>: sieve: msgid=<1602613901.316303.1764609174048@email.ionos.de>: vacation action: sent vacation response to <someexternal.user@external.net>

The difference is the domain in the msgid (the SMTP host configured in the Mail Relay is smtp.ionos.de). Maybe the SMTP host doesn’t accept the message. Can I check this anywhere? I don’t find anything related in the logs.

Sorry for so many questions… :grimacing:

Update

Seems it’s a misconfiguration. Sending to from internal Roundcube to an external email address works, but when the sieve vacation action is triggered, the verbose log shows something like

[...] 3A7808203F7: to=<someexternal.user@external.net>, relay=smtp.ionos.de[213.165.67.113]:587, delay=1, delays=0.46/0.01/0.49/0.04, dsn=5.0.0, status=bounced (host smtp.ionos.de[213.165.67.113] said: 550-Requested action not taken: mailbox unavailable 550-Sender address is not allowed. 550 1M6DOg-1vSLHM0tc8-002uGo (in reply to MAIL FROM command))

I currently can’t figure out what the vacation sieve filter sets as sender address. Seems it’s not the “Reply sender address” configured in the filter as this would be a valid address.

The “Reply sender address” is used when set. If it’s not set, the address in the “My e-mail addresses” field is used to send the autoreply.
Are the addresses allowed on the ionos smarthost?
Maybe you need to setup an identity in Roundcube, see also Roundcube vacation / autoreply / out of office email plugin, how to find / enable? - #23 by mrmarkuz

EDIT:

ns8-fetchmail should work. The configuration is explained here.
Did you set the right permissions (700) for the fetchmailrc file?

To check the log if it’s running:

runagent -m fetchmail1 tail -f log/fetchmail.log

To run fetchmail manually to probably catch errors:

runagent -m fetchmail1 podman exec fetchmail /usr/bin/fetchmail -d0 -v -f /etc/fetchmail/fetchmailrc

I upgraded the app, see release notes.

1 Like

Thanks for your update @mrmarkuz !

I still cannot figure it out:

  • If I configure the Mail-Relay (of the Nethserver 8 Mail App) with a Default rule (to send every email regardless of domain), I can send out emails (any email with domain example.com) with Roundcube, accepted by Ionos.
    For the vacation filter I configured the same email address as the internal address, first.user@example.com for “Reply sender address” and “My e-mail addresses”.
    But Ionos refuses the auto-reply email with
Dec  2 11:12:28 postfix/smtp[581]: D54539446A4: to=<test@external.net>, relay=smtp.ionos.de[213.165.67.97]:587, delay=0.58, delays=0.09/0.01/0.45/0.03, dsn=5.0.0, status=bounced (host smtp.ionos.de[213.165.67.97] said: 550-Requested action not taken: mailbox unavailable 550-Sender address is not allowed. 550 1N95mR-1wBGOp1pbz-00sxVn (in reply to MAIL FROM command)) 
  • If I configure the NS8 Mail-Relay to only send for example.com, I can send out mails with Roundcube (like above), accepted by Ionos.
    But Ionos refuses the auto-reply email with
Dec  2 11:08:14 postfix/smtp[463]: 37E29948454: host mx01.ionos.de[217.72.192.67] refused to talk to me: 554-kundenserver.de (mxeue103) Nemesis ESMTP Service not available 554-No SMTP service 554-Invalid DNS PTR resource record 554 [...]

So it seems the auto reply email has a different domain configured for the sender (not example.com).

Is there any way to check the vacation email? I don’t see the email in the logs (though looking at the journal’s verbose logs).

EDIT:

BTW, an internal vacation auto-reply email is delivered with this header (sent from user.zwei@example.com to first.user@example.com):

Return-Path: <>
Delivered-To: user.zwei@zeus2.example.com.localhost
Received: from zeus2.example.com
    by zeus2.example.com with LMTP
    id uN2yG3TILmllBgAAYRK68w
    (envelope-from <>)
    for <user.zwei@zeus2.example.com.localhost>; Tue, 02 Dec 2025 11:07:32 +0000
Received: from zeus2 (localhost [127.0.0.1])
    by zeus2.example.com (Postfix) with ESMTP id 1192E948456
    for <user.zwei@example.com>; Tue, 02 Dec 2025 11:07:32 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=default;
    t=1764673652;
    [...]
X-Sieve: Pigeonhole Sieve 0.5.21.1 (49005e73)
Message-ID: <dovecot-sieve-1764673652-57552-0@zeus2.example.com>
Date: Tue, 02 Dec 2025 11:07:32 +0000
From: noreply@example.com
To: <user.zwei@example.com>
Subject: U2
In-Reply-To: <554a927745fdfb78bbb8a0445742bad3@example.com>
References: <554a927745fdfb78bbb8a0445742bad3@example.com>
Auto-Submitted: auto-replied (vacation)
Precedence: bulk
X-Auto-Response-Suppress: All
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Rspamd-Flag-Threshold: 6

Usually it should be the same sender address as for the internal vacation mail.

You could use the sieve-test command to check the used sender mail address.

Enter dovecot container:

runagent -m mail1 podman exec -ti dovecot sh

Create test mail (just copy the source of a sent testmail into the mailfile file)

vi mailfile

Execute test:

sieve-test first.user/sieve/roundcube.sieve mailfile

In the result you should see the sender address of the vacation mail:

Performed actions:

 * send vacation message:
    => seconds : 604800
    => subject : Auto reply
    => from    : noreply@example.com

Thank you @mrmarkuz !

As expected, the filter works as configured (and is working for internal email), this is the result.

Performed actions:

 * send vacation message:
    => seconds : 604800
    => subject : Urlaub 7
    => from    : noreply@example.com

And: if I set the Mail/Settings/Relay/Always BCC address to an internal email address, the vacation email is also forwarded and received, only the Relay to the external email address fails. :zany_face:

Is there any chance to debug the Relay?

I tried an NS7 as smarthost using a default relay rule on NS8 and it worked.

Maybe there’s a way to check the logs at ionos?

Maybe you need to create a “noreply” account at ionos so the sender address “noreply@example.com” is allowed?

Did you already try to remove the “Reply sender address” and just keep the “My e-mail addresses” field in the Roundcube filter so the mail should be sent with the user mail address instead of “noreply@example.com”?

Please also search for “vacation” in the mail log to hopefully get some info about the sent vacation mail.

EDIT:

Maybe it makes a difference how fetchmail is configured, my config looks like: (192.168.10.123 is the LAN IP of the NS8)

poll my.mailserver.tld proto imap port 993
    user "markus" password "secret" ssl keep is "markus@example.com" here smtphost 192.168.10.123

Yes, tried this also. Same result.

Yes, tried all variants that came to my head.

I now debugged the SMTP session and it looks like when the email is received with fetchmail the vacation filter creates a reply email without a from address (but only for the email to be sent to the external address? :exploding_head:).

This is what I found in the verbose logs:

Dec  2 15:41:06 postfix/smtp[1263]: > smtp.ionos.de[213.165.67.97]:587: MAIL FROM:<> SIZE=754 BODY=8BITMIME
[...]
send attr reason = host smtp.ionos.de[213.165.67.97] said: 550-Requested action not taken: mailbox unavailable 550-Sender address is not allowed. 550 1MG90u-1vIo4E0nlM-00HJG8 (in reply to MAIL FROM command)

Does it make any difference in which context fetchmail runs?

I’ll check the fetchmail config.

1 Like

I tried it now with a not-catchall variant (close to your fetchmail configuration, single email address, but POP3) and it also gave me the incorrect result (vacation email bounced).

I’m going to wipe the server and reinstall it, maybe the countless failed NS7 migrations cause the problem. Though I completely uninstalled NS8 and reinstalled it today.

I’m gonna close this thread and open a new one, the problem now is not directly related to the topic.

1 Like