1

On Debian 10 I've set up Dovecot and Postfix with Spamassassin working just fine, but when I try to set up forwarding to a remote e-mail with virtual alias, the message bounces.

I tried both of the suggestions by user Blaatpratt in this thread, but I couldn't get either one to work Postifx - Dovecot unable to send emails "status=bounced (user unknown)". To me it seems like the best option if it is possible to get it to work, because it doesn't require me to install any more additional software.

In this example, both mymaindomain.com and mydomain.com are on the server running dovecot, but remoteemail.com is hosted somewhere else.

With spamassassin enabled my postfix master.cf looks like the following:

master.cf

smtp      inet  n       -       n       -       -       smtpd
  -o content_filter=spamassassin
#smtp      inet  n       -       -       -       1       postscreen
#smtpd     pass  -       -       -       -       -       smtpd
#dnsblog   unix  -       -       -       -       0       dnsblog
#tlsproxy  unix  -       -       -       -       0       tlsproxy
submission inet n       -       y      -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_sasl_type=dovecot
  -o smtpd_sasl_path=private/auth
  -o smtpd_reject_unlisted_recipient=no
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING
  -o content_filter=spamassassin
smtps     inet  n       -       -       -       -       smtpd
  -o syslog_name=postfix/smtps
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_sasl_type=dovecot
  -o smtpd_sasl_path=private/auth
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING
  -o content_filter=spamassassin

...

spamassassin unix -     n   n   -   -   pipe
    flags=DROhu user=vmail:vmail argv=/usr/bin/spamc -f -e 
    /usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}

If I completely remove spamassassin as below, forwarding works again.

smtp       inet  n       -       y       -       -       smtpd
smtps      inet  n       -       y       -       -       smtpd
submission inet  n       -       y       -       -       smtpd

Here is the output of /var/log/mail.log during transmission:

Aug 28 19:30:28 localhost postfix/smtpd[8332]: connect from mail-lf1-x135.google.com[2a00:1450:4864:20::135]
Aug 28 19:30:29 localhost postfix/smtpd[8332]: 33F5A44818: client=mail-lf1-x135.google.com[2a00:1450:4864:20::135]
Aug 28 19:30:29 localhost postfix/cleanup[8337]: 33F5A44818: message-id=<6e6d897f-23ab-d1bb-9a4f-bc79a0f39cf7@gmail.com>
Aug 28 19:30:29 localhost postfix/qmgr[15254]: 33F5A44818: from=<mytestaccount@gmail.com>, size=2832, nrcpt=1 (queue active)
Aug 28 19:30:29 localhost spamd[13839]: spamd: connection from ::1 [::1]:51484 to port 783, fd 5
Aug 28 19:30:29 localhost spamd[13839]: spamd: setuid to vmail succeeded
Aug 28 19:30:29 localhost spamd[13839]: spamd: processing message <6e6d897f-23ab-d1bb-9a4f-bc79a0f39cf7@gmail.com> for vmail:5000
Aug 28 19:30:29 localhost postfix/smtpd[8332]: disconnect from mail-lf1-x135.google.com[2a00:1450:4864:20::135] ehlo=2 starttls=1 mail=1 rcpt=1 bdat=1 quit=1 commands=7
Aug 28 19:30:29 localhost spamd[13839]: spamd: clean message (-0.2/5.0) for vmail:5000 in 0.1 seconds, 2887 bytes.
Aug 28 19:30:29 localhost spamd[13839]: spamd: result: . 0 - DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_PASS scantime=0.1,size=2887,user=vmail,uid=5000,required_score=5.0,rhost=::1,raddr=::1,rport=51484,mid=<6e6d897f-23ab-d1bb-9a4f-bc79a0f39cf7@gmail.com>,autolearn=ham autolearn_force=no
Aug 28 19:30:29 localhost postfix/pipe[8338]: 33F5A44818: to=<other@remoteemail.com>, orig_to=<me@mydomain.com>, relay=spamassassin, delay=0.17, delays=0.01/0/0/0.16, dsn=5.1.1, status=bounced (user unknown)
Aug 28 19:30:29 localhost postfix/cleanup[8337]: 5C38F4482F: message-id=<20190828193029.5C38F4482F@mymaindomain.com>
Aug 28 19:30:29 localhost postfix/qmgr[15254]: 5C38F4482F: from=<>, size=4645, nrcpt=1 (queue active)
Aug 28 19:30:29 localhost postfix/bounce[8343]: 33F5A44818: sender non-delivery notification: 5C38F4482F
Aug 28 19:30:29 localhost postfix/qmgr[15254]: 33F5A44818: removed
Aug 28 19:30:29 localhost spamd[13838]: prefork: child states: II
Aug 28 19:30:29 localhost postfix/smtp[8344]: 5C38F4482F: to=<mytestaccount@gmail.com>, relay=gmail-smtp-in.l.google.com[64.233.184.27]:25, delay=0.33, delays=0/0/0.08/0.24, dsn=2.0.0, status=sent (250 2.0.0 OK  1567020629 n6si222998wmi.24 - gsmtp)
Aug 28 19:30:29 localhost postfix/qmgr[15254]: 5C38F4482F: removed

Here is the output of dovecot -n

https://pastebin.com/QwHx891B

**Here is the output of postconf -n **

https://pastebin.com/2n3g9xh5

Can anyone see or know what's wrong? Please help, it would be greatly appreciated. From how I understand my configuration at the end of the master.cf, dovecot is handling the sending of mail to the forwarded address, because dovecot is configured to automatically save spam to the Junk folder with sieve. Can I somehow let dovecot know about the hosts in the alias table in the SQL database in my installation?

simernes
  • 121
  • 1
  • 6

1 Answers1

0

I had similar problem. The problem is really, that dovecot as local delivery agent (LDA) has no idea about /etc/aliases. So I've decided to implement my own LDA as a simple shell script. You can use my script as a skeleton for your requirements. See my question and answer here and don't forget to score my answer.

Tibor Nagy
  • 197
  • 1
  • 11