Heho,
funny. Anything else the dovecot log is spitting out then?

Hard to debug through mail, thoug. Lemme see if i can quickly setup a
mailer to test this with your config. Could you send me a pkg_info -m
off-list?

With best regards,
Tobias

On Sun, 2023-04-09 at 23:21 +0200, Benjamin Stürz wrote:
> Hello Tobias,
> 
> I assume it's `getent passwd`, because it needs a database.
> This is my output:
> vmail:*:2000:2000:Virtual Mail Account:/var/vmail:/sbin/nologin
> 
> On 09.04.23 23:17, Tobias Fiebig wrote:
> > Heho,
> > 
> > can you do a `getent|grep vmail` on your system? That sounds like
> > you
> > haven't fully configured the virtual setup?
> > 
> > With best regards,
> > Tobias
> > 
> > On Sun, 2023-04-09 at 23:15 +0200, Benjamin Stürz wrote:
> > > Hello Tobias,
> > > 
> > > Thanks for your reply.
> > > 
> > > I put your script into
> > > /usr/local/lib/dovecot/sieve/redirect.sieve
> > > and compiled it with sievec.
> > > 
> > > I also put
> > >   >         sieve_after =
> > > file:/usr/local/lib/dovecot/sieve/redirect.sieve
> > > into my plugin section and enabled lmtp in both dovecot and
> > > smtpd.
> > > 
> > > Unfortunately this caused errors like:
> > >   >
> > > a42fc59a8f9aa94a|inet4|mda|auth|be...@stuerz.xyz
> > > > be...@stuerz.xyz
> > > > |be...@stuerz.xyz|1681074451|1681074451|0|1|pending|
> > > 5|"mail.lmtp:
> > > LMTP server error: 550 5.1.1 <vmail> User doesn't exist: vmail"
> > > 
> > > when sending a test email to myself.
> > > 
> > > I then removed "virtual <virtuals>" from my smtpd.conf and it
> > > replaced
> > > "vmail" with "benni" (not be...@stuerz.xyz).
> > > 
> > > I have reverted the change in smtpd.conf again.
> > > 
> > > 
> > > My full configs:
> > > 
> > > /etc/dovecot/local.conf:
> > > 
> > > > auth_mechanisms = plain login
> > > > first_valid_uid = 2000
> > > > first_valid_gid = 2000
> > > > mail_plugin_dir = /usr/local/lib/dovecot
> > > > managesieve_notify_capability = mailto
> > > > managesieve_sieve_capability = fileinto reject envelope
> > > > encoded-
> > > > character vacation subaddress comparator-i;ascii-numeric
> > > > relational
> > > > regex  imap4flags copy include variables body enotify
> > > > environment
> > > > mailbox date index ihave duplicate mime foreverypart
> > > > extracttext
> > > > imapsieve vnd.dovecot.imapsieve
> > > > mbox_write_locks = fcntl
> > > > mmap_disable = yes
> > > > 
> > > > passdb {
> > > >          args = scheme=CRYPT username_format=%u
> > > > /etc/mail/credentials.dovecot
> > > >          driver = passwd-file
> > > >          name =
> > > > }
> > > > 
> > > > mail_location =
> > > > maildir:/var/vmail/%d/%n:INBOX=/var/vmail/%d/%n/Inbox:LAYOUT=fs
> > > > namespace inbox {
> > > >          inbox = yes
> > > >          mailbox Drafts {
> > > >                  auto = subscribe
> > > >                  special_use = \Drafts
> > > >          }
> > > >          mailbox Junk {
> > > >                  auto = subscribe
> > > >                  special_use = \Junk
> > > >                  autoexpunge = 30d
> > > >          }
> > > >          mailbox Sent {
> > > >                  auto = subscribe
> > > >                  special_use = \Sent
> > > >          }
> > > >          mailbox Trash {
> > > >                  auto = subscribe
> > > >                  special_use = \Trash
> > > >          }
> > > >          mailbox Archive {
> > > >                  auto = subscribe
> > > >                  special_use = \Archive
> > > >          }
> > > > }
> > > > 
> > > > plugin {
> > > >          imapsieve_mailbox1_before =
> > > > file:/usr/local/lib/dovecot/sieve/report-spam.sieve
> > > >          imapsieve_mailbox1_causes = COPY
> > > >          imapsieve_mailbox1_name = Junk
> > > >          imapsieve_mailbox2_before =
> > > > file:/usr/local/lib/dovecot/sieve/report-ham.sieve
> > > >          imapsieve_mailbox2_causes = COPY
> > > >          imapsieve_mailbox2_from = Junk
> > > >          imapsieve_mailbox2_name = *
> > > >          sieve_after =
> > > > file:/usr/local/lib/dovecot/sieve/redirect.sieve
> > > >          sieve = file:~/sieve;active=~/.dovecot.sieve
> > > >          sieve_global_extensions = +vnd.dovecot.pipe
> > > > +vnd.dovecot.environment
> > > >          sieve_pipe_bin_dir = /usr/local/lib/dovecot/sieve
> > > >          sieve_plugins = sieve_imapsieve sieve_extprograms
> > > > }
> > > > 
> > > > protocols = imap sieve lmtp
> > > > 
> > > > service imap-login {
> > > >          inet_listener imap {
> > > >                  port = 0
> > > >          }
> > > > }
> > > > 
> > > > service managesieve-login {
> > > >          inet_listener sieve {
> > > >                  port = 4190
> > > >          }
> > > > 
> > > >          inet_listener sieve_deprecated {
> > > >                  port = 2000
> > > >          }
> > > > }
> > > > 
> > > > ssl_cert = </etc/ssl/mixdown.me.crt
> > > > ssl_key = </etc/ssl/private/mixdown.me.key
> > > > 
> > > > userdb {
> > > >          args = username_format=%u
> > > > /etc/mail/credentials.dovecot
> > > >          driver = passwd-file
> > > >          name =
> > > > }
> > > > 
> > > > protocol imap {
> > > >          mail_plugins = " imap_sieve"
> > > > }
> > > > 
> > > > protocol lda {
> > > >          mail_plugins = $mail_plugins sieve
> > > > }
> > > > 
> > > > protocol lmtp {
> > > >          mail_plugins = $mail_plugins sieve
> > > > }
> > > 
> > > 
> > > /etc/mail/smtpd.conf:
> > > > #       $OpenBSD: smtpd.conf,v 1.14 2019/11/26 20:14:38 gilles
> > > > Exp
> > > > $
> > > > 
> > > > # This is the smtpd server system-wide configuration file.
> > > > # See smtpd.conf(5) for more information.
> > > > 
> > > > pki "mail" cert "/etc/ssl/mixdown.me.fullchain.pem"
> > > > pki "mail" key "/etc/ssl/private/mixdown.me.key"
> > > > 
> > > > table aliases file:/etc/mail/aliases
> > > > table credentials file:/etc/mail/credentials.smtpd
> > > > table virtuals file:/etc/mail/virtuals
> > > > 
> > > > filter dkim_sign proc-exec "filter-dkimsign -d mixdown.me -s
> > > > selector1 -k /etc/mail/dkim/mixdown.me.key" user _dkimsign
> > > > group
> > > > _dkimsign
> > > > #filter check_fcrdns phase connect match !fcrdns disconnect
> > > > "550 no
> > > > FCrDNS"
> > > > #filter check_rdns phase connect match !rdns disconnect "550 no
> > > > rDNS"
> > > > filter rspamd proc-exec "/usr/local/libexec/smtpd/filter-
> > > > rspamd"
> > > > filter filters chain { dkim_sign, rspamd }
> > > > 
> > > > listen on all tls pki "mail" #filter "filters"
> > > > listen on egress port submission tls-require pki "mail" auth
> > > > <credentials> filter "filters"
> > > > listen on egress port smtps tls-require pki "mail" auth
> > > > <credentials> filter "filters"
> > > > 
> > > > action "local_mail" mbox alias <aliases>
> > > > #action "domain_mail" maildir
> > > > "/var/vmail/%{dest.domain:lowercase}/%{dest.user:lowercase|stri
> > > > p}/I
> > > > nbox" virtual <virtuals>
> > > > action "domain_mail" lmtp "/var/dovecot/lmtp" #virtual
> > > > <virtuals>
> > > > action "outbound" relay
> > > > 
> > > > match from any for domain "mixdown.me" action "domain_mail"
> > > > match from any for domain "stuerz.art" action "domain_mail"
> > > > match from any for domain "stuerz.xyz" action "domain_mail"
> > > > match from local for local action "local_mail"
> > > > match from auth for any action "outbound"
> > > > match from local for any action "outbound"
> > > > match from any for any reject
> > > 
> > > 
> > > 
> > > On 09.04.23 22:28, Tobias Fiebig wrote:
> > > > Heho,
> > > > 
> > > > The documentation for sieve is here:
> > > > https://doc.dovecot.org/configuration_manual/sieve/configuration/
> > > > 
> > > > Sieve is its own script language for mail filtering. Once you
> > > > configured it, you can either use pidgeonhole/managesieve to
> > > > edit
> > > > the
> > > > sieverc, or just write one to the right path on your server.
> > > > 
> > > > You are looking for a sieve script like this (does what you
> > > > asked
> > > > for
> > > > for my mail account for a couple of years now.):
> > > > 
> > > > """
> > > > require ["variables", "envelope", "fileinto", "subaddress"];
> > > > 
> > > > if envelope :matches :detail "to" "*" {
> > > >           set :lower "name" "${1}";
> > > > }
> > > > 
> > > > if string :is "${name}" "" {
> > > >           fileinto "INBOX";
> > > >           stop;
> > > > } else {
> > > >           fileinto "delimiters.${name}";
> > > >           stop;
> > > > }
> > > > """
> > > > 
> > > > With best regards,
> > > > Tobias
> > > > 
> > > > 
> > > > On Sun, 2023-04-09 at 22:21 +0200, Benjamin Stürz wrote:
> > > > > Hello Michael,
> > > > > 
> > > > > Thanks for helping me!
> > > > > 
> > > > > I too use dovecot, but I'm not really familiar with it.
> > > > > That's why I took most of my config from a tutorial.
> > > > > 
> > > > > As far as I can tell, I have to put something like this into
> > > > > my
> > > > > config:
> > > > > > protocol lmtp {
> > > > > >     mail_plugins = $mail_plugins sieve
> > > > > > }
> > > > > But how do I connect it with my script?
> > > > > 
> > > > > I'm thinking of using a script like this:
> > > > > > #!/bin/sh
> > > > > > 
> > > > > > # Usage: $0 user[+tag]@domain.tld
> > > > > > 
> > > > > > # user[+tag]
> > > > > > user_tag=$(echo "$1" | cut -d@ -f1)
> > > > > > 
> > > > > > # domain.tld
> > > > > > domain=$(echo "$1" | cut -d@ -f2)
> > > > > > 
> > > > > > # user
> > > > > > user=$(echo "${user_tag}" | cut -d+ -f1)
> > > > > > 
> > > > > > # [tag]
> > > > > > tag=$(echo "${user_tag}" | cut -d+ -f2)
> > > > > > 
> > > > > > prefix="/var/vmail/${domain}/${user}"
> > > > > > 
> > > > > > [ "$tag" ] && echo "${prefix}/${tag}" || echo
> > > > > > "${prefix}/Inbox"
> > > > > 
> > > > > 
> > > > > My current /etc/dovecot/local.conf:
> > > > > > auth_mechanisms = plain login
> > > > > > first_valid_uid = 2000
> > > > > > first_valid_gid = 2000
> > > > > > mail_plugin_dir = /usr/local/lib/dovecot
> > > > > > managesieve_notify_capability = mailto
> > > > > > managesieve_sieve_capability = fileinto reject envelope
> > > > > > encoded-
> > > > > > character vacation subaddress comparator-i;ascii-numeric
> > > > > > relational
> > > > > > regex  imap4flags copy include variables body enotify
> > > > > > environment
> > > > > > mailbox date index ihave duplicate mime foreverypart
> > > > > > extracttext
> > > > > > imapsieve vnd.dovecot.imapsieve
> > > > > > mbox_write_locks = fcntl
> > > > > > mmap_disable = yes
> > > > > > 
> > > > > > passdb {
> > > > > >           args = scheme=CRYPT username_format=%u
> > > > > > /etc/mail/credentials.dovecot
> > > > > >           driver = passwd-file
> > > > > >           name =
> > > > > > }
> > > > > > 
> > > > > > mail_location =
> > > > > > maildir:/var/vmail/%d/%n:INBOX=/var/vmail/%d/%n/Inbox:LAYOU
> > > > > > T=fs
> > > > > > namespace inbox {
> > > > > >           inbox = yes
> > > > > >           mailbox Drafts {
> > > > > >                   auto = subscribe
> > > > > >                   special_use = \Drafts
> > > > > >           }
> > > > > >           mailbox Junk {
> > > > > >                   auto = subscribe
> > > > > >                   special_use = \Junk
> > > > > >                   autoexpunge = 30d
> > > > > >           }
> > > > > >           mailbox Sent {
> > > > > >                   auto = subscribe
> > > > > >                   special_use = \Sent
> > > > > >           }
> > > > > >           mailbox Trash {
> > > > > >                   auto = subscribe
> > > > > >                   special_use = \Trash
> > > > > >           }
> > > > > >           mailbox Archive {
> > > > > >                   auto = subscribe
> > > > > >                   special_use = \Archive
> > > > > >           }
> > > > > > }
> > > > > > 
> > > > > > plugin {
> > > > > >           imapsieve_mailbox1_before =
> > > > > > file:/usr/local/lib/dovecot/sieve/report-spam.sieve
> > > > > >           imapsieve_mailbox1_causes = COPY
> > > > > >           imapsieve_mailbox1_name = Junk
> > > > > >           imapsieve_mailbox2_before =
> > > > > > file:/usr/local/lib/dovecot/sieve/report-ham.sieve
> > > > > >           imapsieve_mailbox2_causes = COPY
> > > > > >           imapsieve_mailbox2_from = Junk
> > > > > >           imapsieve_mailbox2_name = *
> > > > > >           sieve = file:~/sieve;active=~/.dovecot.sieve
> > > > > >           sieve_global_extensions = +vnd.dovecot.pipe
> > > > > > +vnd.dovecot.environment
> > > > > >           sieve_pipe_bin_dir = /usr/local/lib/dovecot/sieve
> > > > > >           sieve_plugins = sieve_imapsieve sieve_extprograms
> > > > > > }
> > > > > > 
> > > > > > protocols = imap sieve
> > > > > > 
> > > > > > service imap-login {
> > > > > >           inet_listener imap {
> > > > > >                   port = 0
> > > > > >           }
> > > > > > }
> > > > > > 
> > > > > > service managesieve-login {
> > > > > >           inet_listener sieve {
> > > > > >                   port = 4190
> > > > > >           }
> > > > > > 
> > > > > >           inet_listener sieve_deprecated {
> > > > > >                   port = 2000
> > > > > >           }
> > > > > > }
> > > > > > 
> > > > > > ssl_cert = </etc/ssl/mixdown.me.crt
> > > > > > ssl_key = </etc/ssl/private/mixdown.me.key
> > > > > > 
> > > > > > userdb {
> > > > > >           args = username_format=%u
> > > > > > /etc/mail/credentials.dovecot
> > > > > >           driver = passwd-file
> > > > > >           name =
> > > > > > }
> > > > > > 
> > > > > > protocol imap {
> > > > > >           mail_plugins = " imap_sieve"
> > > > > > }
> > > > > 
> > > > > 
> > > > > On 09.04.23 22:00, Michael Breuer wrote:
> > > > > > Hello Benjamin,
> > > > > > 
> > > > > > what mda do you use? I use dovecot and a sieve script to
> > > > > > process
> > > > > > incoming mail.
> > > > > > 
> > > > > > Instead of saving mail directly to maildir, I transfer it
> > > > > > to
> > > > > > the
> > > > > > mda via lmtp. The required changes on the smtpd site would
> > > > > > look
> > > > > > like this:
> > > > > > 
> > > > > > > On 9. Apr 2023, at 16:04, Benjamin Stürz
> > > > > > > <benni+open...@stuerz.xyz> wrote:
> > > > > > > 
> > > > > > > I think this line has to be changed:
> > > > > > > action "domain_mail" maildir
> > > > > > > "/var/vmail/%{dest.domain:lowercase}/%{dest.user:lowercas
> > > > > > > e|st
> > > > > > > rip}
> > > > > > > /Inbox" virtual <virtuals>
> > > > > > 
> > > > > > action "domain_mail" lmtp "/var/dovecot/lmtp" virtual
> > > > > > <virtuals>
> > > > > > 
> > > > > > In dovecot, you need to activate&configure the sieve plugin
> > > > > > and
> > > > > > a
> > > > > > script for your user account.
> > > > > > 
> > > > > > 
> > > > > 
> > > > 
> > > 
> > 
> 

-- 
Dr.-Ing. Tobias Fiebig
T +31 616 80 98 99
M tob...@fiebig.nl


Reply via email to