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: Postfixadmin/MySQL/Dovecot 2 and quota

2020-04-01 Thread Debdut
It worked for me, I'm having same problem changing to:

/etc/dovecot/conf.d/auth-sql.conf.ext:

userdb {
  driver = sql
  args = /etc/dovecot/dovecot-sql.conf.ext
}

&

/etc/dovecot/dovecot-sql.conf.ext:

user_query = SELECT CONCAT('/home/vmail/mailbox/vhosts/',maildir) AS home,
CONCAT('maildir:/home/vmail/mailbox/vhosts/',maildir) AS mail, 5000 AS uid,
5000 AS gid, CONCAT('*:bytes=', IF(mailbox.quota = 0,
domain.maxquota*1048576, mailbox.quota)) AS quota_rule FROM mailbox, domain
WHERE username = '%u' AND mailbox.active = '1' AND domain.domain = '%d' AND
domain.active = '1'

Done the trick!!!

A very very thank you to you <3



--
Sent from: http://dovecot.2317879.n4.nabble.com/


Re: sieve compile error

2020-04-01 Thread Johannes Rohr
Am Mittwoch, den 01.04.2020, 15:41 +0300 schrieb Sami Ketola:
> Hi,
> 
> "If personal user scripts also need to directly access external
> programs, the extensions need to be added to the sieve_extensions
> setting. "
> from https://wiki2.dovecot.org/Pigeonhole/Sieve/Plugins/Extprograms
> 
> so is this a global sieve script or personal sieve script? I think it
> is personal script as it is triggered by imapsieve.

This is a global script. However, what now seems to have fixed it is
adding 

sieve_plugins = sieve_imapsieve 
and 

changing 

sieve_global_extensions = +vnd.dovecot.environment +vnd.dovecot.debug 
to 

sieve_global_extensions = +vnd.dovecot.environment +vnd.dovecot.debug
+vnd.dovecot.pipe
in conf.d/90-sieve.conf

Obviously, having these additions in the settings for the IMAP plugin
wasn't sufficient.. Hm...

Cheers,

Johannes

 


Re: sieve compile error

2020-04-01 Thread Sami Ketola
Hi,

"If personal user scripts also need to directly access external programs, the 
extensions need to be added to the sieve_extensions setting. "

from https://wiki2.dovecot.org/Pigeonhole/Sieve/Plugins/Extprograms 


so is this a global sieve script or personal sieve script? I think it is 
personal script as it is triggered by imapsieve.

Sami

> On 1 Apr 2020, at 15.35, Johannes Rohr  wrote:
> 
> Dear all, I try to recompile my learn_ham.sieve script, which fails with the 
> message
> 
> root@ida :/etc/dovecot# sievec 
> sieve-scripts/report-ham.sieve 
> 
> report-ham: line 1: error: require command: unknown Sieve capability 
> `vnd.dovecot.pipe'.
> report-ham: line 1: error: require command: unknown Sieve capability 
> `imapsieve'.
> report-ham: line 19: error: unknown command 'pipe' (only reported once at 
> first occurrence).
> report-ham: error: validation failed.
> sievec(root): Fatal: failed to compile sieve script 
> 'sieve-scripts/report-ham.sieve'
> 
> Yes, in conf.d/20-imap.conf, imapsieve and vnd.dovecot.pipe are explicitly 
> enabled:
> 
> protocol imap {
>   mail_plugins = $mail_plugins imap_sieve imap_acl
>   mail_max_userip_connections = 50
> 
> plugin {
> sieve_plugins = sieve_imapsieve sieve_extprograms
>   # From elsewhere to Spam folder
>   imapsieve_mailbox1_name = Spam
>   imapsieve_mailbox1_causes = COPY
>   imapsieve_mailbox1_before = 
> file:/etc/dovecot/sieve-scripts/report-spam.sieve
>   # From Spam folder to elsewhere
>   imapsieve_mailbox2_name = *
>   imapsieve_mailbox2_from = Spam
>   imapsieve_mailbox2_causes = COPY
>   imapsieve_mailbox2_before = file:/etc/dovecot/sieve-scripts/report-ham.sieve
> #
> sieve_pipe_bin_dir = /etc/dovecot/sieve-scripts
> sieve_global_extensions = +vnd.dovecot.execute +vnd.dovecot.pipe
> 
>   }
> }
> 
> 
> I am obviously overlooking something here, but what?
> 
> Any hints will be greatly appreciated!
> 
> Johannes



sieve compile error

2020-04-01 Thread Johannes Rohr
Dear all, I try to recompile my learn_ham.sieve script, which fails
with the message
root@ida:/etc/dovecot# sievec sieve-scripts/report-ham.sieve 
report-ham: line 1: error: require command: unknown Sieve capability
`vnd.dovecot.pipe'.report-ham: line 1: error: require command: unknown
Sieve capability `imapsieve'.report-ham: line 19: error: unknown
command 'pipe' (only reported once at first occurrence).report-ham:
error: validation failed.sievec(root): Fatal: failed to compile sieve
script 'sieve-scripts/report-ham.sieve'
Yes, in conf.d/20-imap.conf, imapsieve and vnd.dovecot.pipe are
explicitly enabled:
protocol imap {  mail_plugins = $mail_plugins imap_sieve imap_acl 
mail_max_userip_connections = 50
plugin {sieve_plugins = sieve_imapsieve sieve_extprograms  # From
elsewhere to Spam folder  imapsieve_mailbox1_name = Spam 
imapsieve_mailbox1_causes = COPY  imapsieve_mailbox1_before =
file:/etc/dovecot/sieve-scripts/report-spam.sieve  # From Spam folder
to elsewhere  imapsieve_mailbox2_name = *  imapsieve_mailbox2_from =
Spam  imapsieve_mailbox2_causes = COPY  imapsieve_mailbox2_before =
file:/etc/dovecot/sieve-scripts/report-ham.sieve#sieve_pipe_bin_dir =
/etc/dovecot/sieve-scriptssieve_global_extensions =
+vnd.dovecot.execute +vnd.dovecot.pipe
}}

I am obviously overlooking something here, but what?
Any hints will be greatly appreciated!
Johannes