Re: Disable Dovecot LDA

2020-04-01 Thread Dauser Martin Johannes
On Dienstag, 31. März 2020 21:14:26 CEST Adam Raszkiewicz wrote:
> But then it loops again when get back to the postfix as an incoming message
> (doesn't know that a...@localdomain.com is located on that Dovecot)
+
> Is there any way to disable Dovecot LDA? I want to always send email via 
> postfix and relay server even it will be a local delivery within the Dovecot
> server
>
>Thanks,
>Adam

Why should a disabled LDA or a relayhost help in this matter? Honestly, who is 
sending what to where anyway? 

I mean Dovecot is an IMAP-Server: It receives emails from Postfix and 
mailclients connect to Dovecot to get these mails. When a mailclient sends an 
email it connects to Postfix not to Dovecot, so a delivery "within Dovecot" 
isn't really happening. Dovecot's LDA has options to send (bounce) mails back 
to Postfix. I guess loops occur there?

WHO doesn't know that a...@localdomain.com is located on Dovecot -- Dovecot 
itself (= unknown recipient or perhaps permission problems while saving the 
mail) or Postfix (= no transport to Dovecot)? 

Martin







Re: Send local generated mails via gateway back to LDA Dovecot

2020-04-01 Thread Dauser Martin Johannes
Well as you need LDA to deliver emails from postfix to dovecot,  you can't just 
turn it off. What you need is a second smtp daemon within postfix, which is 
only responsible for local originating emails and is configured to send any 
email to your gateway. This way your second smtpd will send local generated 
mails to your gateway. The gateway will send those mails back to your default 
smtpd and this one will deliver those mails to dovecot -- or where ever you 
configured them to go to.

As email addresses like localpart@localhost aren't useful for your gateway, you 
need to (canonical) rewrite those addresses to an official address.

---

This means your default smtpd must not listen on localhost anymore.
The default entry in master.cf like "smtp  inet  n  -  n  -  -  smtpd" means 
that the smtpd listens on any interface on smtp port number 25. Now you need it 
to listen on the smtp port of your official IP address only. Therefore we will 
override inet_interfaces from main.cf .

Your second smtpd, newly defined in master.cf, inherits the default values from 
main.cf too, so you need to adjust only some. Well and this daemon will listen 
on localhost only.

Note1: This config runs without a chroot environment! If you do, some extra 
adjustments might be necessary. (I don't know for sure.)

Note2: Lines starting with dash (-) should be removed in your config and those 
beginning with plus (+) should be added. Angled brackets (<>) indicate a 
placeholder and they should not be present in your config.


/etc/postfix/master.cf
# ==
# service type  private unpriv  chroot  wakeup  maxproc command + args
# ==
-smtp   inet  n   -   n   -   -   smtpd
+smtp   inet  n   -   n   -   -   smtpd
+  # Incomming mails only from real IP address
   -o inet_interfaces=

+127.0.0.1:25   inet   n  -   n   -   -   smtpd
+  # Incomming mails only from loopback device 
+  # use only if appropriate in your case (postfix version >=2.2) 
+-o inet_interfaces=loopback-only
+  # Incomming mails only from localhost 
+  # use only if appropriate in your case (postfix version < 2.2)
+-o inet_interfaces=localhost,127.0.0.1
+  # Empty mydestination to disable local transport
+-o mydestination=
+  # disable LDA delivery by emptying corresponding config entries
+  # you either use mailbox_command or virtual_mailbox_domains
+-o mailbox_command=
+-o virtual_mailbox_domains=
+  # Use this IP address as client to connect to gateway
+-o smtp_bind_address=
+  # Canonical rewrite for sender and recipient addresses with @localhost
+-o canonical_maps = pcre:/etc/postfix/canonical_localhost.pcre

---

New file /etc/postfix/canonical_localhost.pcre
# This is a Perl Compatible Regular Expression table,
# so no postmap command is needed.

# Address something@localhost becomes something@
# or 
# address something@localhost becomes root@
# CHOOSE ONLY ONE !
#
#/^(.+)@localhost$/   $1@
/^.+@localhost$/   root@

---

Local generated mails, that have no domain information should append the string 
$mydomain instead of default $myorigin (which normally is the FQDN of your 
mailserver).

/etc/postfix/main.cf
- append_at_myorigin = yes
+ append_at_myorigin = no

- append_dot_mydomain = no
+ append_dot_mydomain = yes

---

I guess you already set $relayhost but you can set fallbacks too.

/etc/postfix/main.cf
relayhost = 

+# Optional list of relay hosts 
+smtp_fallback_relay = ,
  

---

Of course you need to restart postfix to apply these changes. 
AND if something breaks don't hold me responsible, use this config at your own 
risk!

Martin


On Dienstag, 31. März 2020 18:35:07 CEST Adam Raszkiewicz wrote:
> Hi,
> 
> Is there any way to disable Dovecot LDA? I want to always send email via
> postfix and relay server even it will be a local delivery within the
> Dovecot server
 
> Thanks,
> Adam






Re: Sieve fileinto copies messages instead of moving them

2019-03-07 Thread Dauser Martin Johannes via dovecot
Micheal, just for your information: "stop;" stops the whole script at
this very line, which means no other rule will be applied on this
message anymore. Most of the time this is desired. Otherwise "elsif"
(and "else" as a catch-all) is your friend.  

require ["fileinto"];

# rule:[check if either SPAM or SPAMSPAM]
if header :contains "subject" "SPAMSPAM"
{
fileinto "SPAM";
}
elsif header :contains "subject" "SPAM"
{
fileinto "MaybeSPAM";
}

# rule:[something else needs to be done with message]
if blah
{
action;
} 


On Thu, 2019-03-07 at 02:57 -0500, Helmut K. C. Tessarek via dovecot
wrote:
> You are missing a stop after the fileinto. Otherwise it will not stop, but
> rather processing the next rule as well.
> 
> Change it to:
> 
> require ["fileinto"];
> # rule:[SPAM]
> if header :contains "subject" "SPAMSPAM"
> {
> fileinto "SPAM";
> stop;
> }
> # rule:[SPAMSPAM]
> if header :contains "subject" "SPAM"
> {
> fileinto "MaybeSPAM";
> stop;
> }
> 
> Cheers,
>   K. C.
>