Dovecot

Fetchmail To MailScanner To Dovecot LDA To Virtual User
To be done.

Sendmail To Dovecot LDA
Local > Sendmail > Dovecot LDA > Virtual User Maildir

Trying to follow http://wiki2.dovecot.org/LDA/Sendmail

dovecot --version

2.0.19

sendmail -d0.1

Version 8.14.4

/etc/mail $ ls

access access.db aliases aliases.db authinfo authinfo.db helpfile local-host-names mailertable mailertable.db sendmail.cf sendmail.mc sendmail.mc.orig statistics submit.cf submit.mc trusted-users virtuserdomains

/etc/mail/sendmail.mc

divert(-1) divert(0)dnl include(`/usr/share/sendmail-cf/m4/cf.m4')dnl VERSIONID(`$Id: sendmail-procmail.mc,v 1.2 2004/12/07 01:59:31 g2boojum Exp $')dnl OSTYPE(linux)dnl DOMAIN(generic)dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1,Name=MTA') DAEMON_OPTIONS(`Port=smtp,Addr=192.168.0.207,Name=MTA') define(`ALIAS_FILE', `/etc/mail/aliases') define(`STATUS_FILE',`/etc/mail/statistics') define(`SMART_HOST',`[auth.smtp.whatever.co.uk]') FEATURE(`authinfo',`hash -o /etc/mail/authinfo.db') FEATURE(`access_db') FEATURE(`relay_entire_domain') FEATURE(`accept_unresolvable_domains') FEATURE(`mailertable') FEATURE(`smrsh',`/usr/sbin/smrsh') FEATURE(`local_lmtp',`/usr/sbin/mail.local') FEATURE(`local_procmail') FEATURE(`no_default_msa') FEATURE(`limited_masquerade') FEATURE(`masquerade_envelope') MASQUERADE_AS(`littlefield.uk.com') MASQUERADE_DOMAIN(`vmware-gentoo-server.littlefield.uk.com') VIRTUSER_DOMAIN_FILE(`/etc/mail/virtuserdomains') MAILER(dovecot) MAILER(procmail) MAILER(smtp) MAILER(local)

/usr/share/sendmail-cf/mailer/dovecot.m4

PUSHDIVERT(-1) _DEFIFNOT(`DOVECOT_MAILER_MAX', `ifdef(`SMTP_MAILER_MAX', `SMTP_MAILER_MAX', `10240000')') _DEFIFNOT(`DOVECOT_MAILER_PATH', `/usr/libexec/dovecot/dovecot-lda') _DEFIFNOT(`DOVECOT_MAILER_FLAGS', `l59DFMPhnu') _DEFIFNOT(`DOVECOT_MAILER_ARGS', `/usr/libexec/dovecot/dovecot-lda -d $u') _DEFIFNOT(`DOVECOT_MAILER_USER', `vmail:vmail') POPDIVERT Mdovecot,   P=DOVECOT_MAILER_PATH, F=DOVECOT_MAILER_FLAGS, S=EnvFromL/HdrFromL, R=EnvToL/HdrToL, _OPTINS(`DOVECOT_MAILER_MAX', `M=', `, ') _OPTINS(`DOVECOT_MAILER_USER', `U=', `, ') T=DNS/RFC822/X-Unix, A=DOVECOT_MAILER_ARGS

/etc/mail/virtuserdomains

littlefield.org.uk

/etc/mail/mailertable

littlefield.org.uk vmail:vmail

/etc/dovecot/conf.d/10-master.conf

service auth { unix_listener auth-userdb { mode = 0600 user = vmail group = vmail }

/home/vmail/

-rw--- 1 vmail vmail 50K 2012-08-05 21:56 fetchmail.log drwx-- 4 vmail vmail 4.0K 2012-08-05 17:30 test@littlefield.org.uk

dovecot-lda

-rwxr-xr-x 1 vmail vmail 23K 2012-08-05 15:27 /usr/libexec/dovecot/dovecot-lda

Results So Far

$ echo "message" |mail -s "test" -v test@littlefield.org.uk |sed 's/^/ /' test@littlefield.org.uk... Connecting to [127.0.0.1] via relay... 220 vmware-gentoo-server.littlefield.uk.com ESMTP Sendmail 8.14.4/8.14.4; Thu, 9 Aug 2012 12:59:23 +0100 >>> EHLO vmware-gentoo-server.littlefield.uk.com 250-vmware-gentoo-server.littlefield.uk.com Hello localhost.localdomain [127.0.0.1], pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-EXPN 250-VERB 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 250-AUTH DIGEST-MD5 CRAM-MD5 250-DELIVERBY 250 HELP >>> VERB 250 2.0.0 Verbose mode >>> MAIL From: SIZE=51 AUTH=root@vmware-gentoo-server.littlefield.uk.com 250 2.1.0 ... Sender ok >>> RCPT To: >>> DATA 554 5.3.5 buildaddr: unknown mailer vmail 503 5.0.0 Need RCPT (recipient) >>> RSET 250 2.0.0 Reset state >>> RSET 250 2.0.0 Reset state root... Using cached ESMTP connection to [127.0.0.1] via relay... >>> MAIL From:<> SIZE=1075 250 2.1.0 <>... Sender ok >>> RCPT To: >>> DATA 050 ... aliased to root 250 2.1.5 ... Recipient ok 354 Enter mail, end with "." on a line by itself >>> . 050 ... Connecting to local... 050 ... Sent 250 2.0.0 q79BxNvN002137 Message accepted for delivery root... Sent (q79BxNvN002137 Message accepted for delivery) Closing connection to [127.0.0.1] >>> QUIT Can't send mail: sendmail process failed with error code 69 221 2.0.0 vmware-gentoo-server.littlefield.uk.com closing connection

/var/log/mail.log

Aug 9 13:07:36 vmware-gentoo-server sendmail[2148]: q79C7aDH002148: from=root, size=51, class=0, nrcpts=1, msgid=<201208091207.q79C7aDH002148@vmware-gentoo-server.littlefield.uk.com>, relay=root@localhost Aug 9 13:07:37 vmware-gentoo-server sm-mta[2149]: q79C7aI9002149: SYSERR(root): buildaddr: unknown mailer vmail Aug 9 13:07:37 vmware-gentoo-server sendmail[2148]: q79C7aDH002148: to=test@littlefield.org.uk, ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30051, relay=[127.0.0.1] [127.0.0.1], dsn=5.3.5, stat=Service unavailable Aug 9 13:07:37 vmware-gentoo-server sm-mta[2149]: q79C7aI9002149: from=, size=51, class=0, nrcpts=0, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1] Aug 9 13:07:37 vmware-gentoo-server sendmail[2148]: q79C7aDH002148: q79C7aDI002148: DSN: Service unavailable

Virtual Users
http://wiki.dovecot.org/HowTo/SimpleVirtualInstall

Fetchmail to Dovecot Deliver LDA to Virtual Users
Internet > Fetchmail > Dovecot LDA > Virtual User Maildir

This will show you how to fetch mail from the internet and deliver it to local virtual email users. Again, I could not find a single web page on the internet which showed this, so I am writing it down now so that someone else doesn't spend 3 hours trying to figure it out. :-(

This example is using IMAP and keeping the emails in the internet server, but you could use POP and delete the emails on the server.

Install Fetchmail

emerge fetchmail

Create the Virtual Mail User

useradd -c "Virtual Mail User" -d /home/vmail -U -m vmail passwd vmail

Create the Fetchmail config file for the user 'vmail' (created for the Virtual Users above) which will go and get then deliver the emails.

cd /home/vmail/ touch .fetchmailrc chown vmail:vmail .fetchmailrc chmod 0700 .fetchmailrc nano .fetchmailrc

This is the magic config file. The Dovecot documentation showed dovecot-lda -f $FROM_ENVELOPE -d $DEST_USERNAME but I could not get this variable to work, so hard coded it instead... at least, for now.

set daemon 300 set logfile /home/vmail/fetchmail.log set no bouncemail set postmaster vmail poll imap.domain.co.uk protocol imap username "test@domain.org.uk" password "mypassword" keep mda "/usr/libexec/dovecot/dovecot-lda -d test@domain.org.uk" preconnect "date >> /home/vmail/fetchmail.log"

Your logs will now show something like the following:-

/home/vmail/fetchmail.log fetchmail: 12 messages (11 seen) for test@domain.org.uk at imap.domain.co.uk. fetchmail: reading message test@domain.org.uk@imap.domain.co.uk:12 of 12 (1426 header octets) (10 body octets) not flushed Sat Aug 4 20:49:16 BST 2012

/var/log/dovecot/dovecot-info.log Aug 04 20:49:17 lda(test@domain.org.uk): Info: msgid=<501D7BF9.7020604@domain.co.uk>: saved mail to INBOX

Sieve
This facility consists of 2 parts - the ManageSieve daemon and the Sieve plugins + scripts.

Add the relevant USE flags and re-install the package...

echo "net-mail/dovecot maildir managesieve sieve" >> /etc/portage/package.use emerge -q dovecot

Uncomment the config file line to enable the ManageSieve daemon and port...

nano /etc/dovecot/conf.d/20-managesieve.conf

protocols = $protocols sieve service managesieve-login { inet_listener sieve { port = 4190 }

Restart Dovecot...

/etc/init.d/dovecot restart

Check the port is open...

netstat -ntap |grep dovecot tcp       0      0 0.0.0.0:143             0.0.0.0:*               LISTEN      32135/dovecot tcp       0      0 0.0.0.0:4190            0.0.0.0:*               LISTEN      32135/dovecot

http://wiki.dovecot.org/ManageSieve/Configuration http://wiki.dovecot.org/LDA/Sieve/Dovecot

Then install the Out Of Office extension for Thunderbird below...

Vacation / Out Of Office Plugin for Mozilla Thunderbird
http://adullact.net/plugins/mediawiki/wiki/milimail/index.php/Out_of_Office

Sieve Settings Server Name: 192.168.0.207 Port: 4190 Authentication: Use login from IMAP Account User Name: test@domain.org.uk Secure Connection: false