Pages

Wednesday, March 13, 2013

Dovecot Error "fchown"


Sometimes we may see the below logs from mail log when we use dovecot in our mail server.

Mar 13 10:14:56 mail dovecot: POP3(abidul): fchown(/home/abidul/mail/.imap/INBOX/dovecot.index.tmp, -1, 8(mail)) failed: Operation not permitted (egid=1079(abidul), group based on /var/mail/abidul)

Mar 13 10:14:56 mail dovecot: POP3(sumanta): fchown(/home/sumanta/mail/.imap/INBOX/dovecot.index.log.newlock, -1, 8(mail)) failed: Operation not permitted (egid=1092(sumanta), group based on /var/mail/sumanta)

Mar 13 10:14:40 mail dovecot: POP3(shehab): fchown(/home/shehab/mail/.imap/INBOX/dovecot.index.cache.lock, -1, 8(mail)) failed: Operation not permitted (egid=1048(shehab), group based on /var/mail/shehab)

Dovecot tried to copy /var/mail/user files group (mail) to the index file directory it was creating (/home/user/mail/.imap/INBOX) but the process didn’t belong to the mail group. As a result the error shows.

To solve the problem just run following command.

#chmod 0600 /var/mail/*

You can also check the mail location and mail group settings from /etc/dovecot/dovecot.conf

mail_location = mbox:~/mail:INBOX=/var/mail/%u

mail_privileged_group = mail

Now check mail log and see the error vanished. 

Wednesday, March 6, 2013

Specific email ID only receive mail from specific domains

Scenerio


Today one of my clients send an email. He has some group email IDs. He wants only native domain users can send mails to those group IDs. 

At first I thought how can it possible? How can I filter incoming mails to a specific email address? But by luck I use POSTFIX. It has lots of option to work with. Here is how I have done it......


 1. At first edit the main.cf file of postfix.


smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/protected_destinations, permit_mynetworks, reject_unauth_destination

smtpd_restriction_classes = insiders_only

insiders_only = check_sender_access hash:/etc/postfix/insiders, reject

[Explanation: smtpd_recipient_restrictions is a postfix parameter, It will check the recipient access by "protected_destinations"- Lets see below what I will put in "protected_destinations"? ]

2. Edit and save the following in "/etc/postfix/protected_destinations"
    xyz@domain.com   insiders_only
    

[How do postfix knows insider_only?? It has been declared in main.cf with "smtpd_restriction_classes" after that I defined the "insiders_only" in postfix by "/etc/postfix/insiders".]

3. Now input /etc/postfix/insiders

   domain.com                      OK       ###matches my.domain and subdomains
   anotherdomain.com       OK       ###matches another.domain and subdomains

4. Now create .db for new files with following commands.

postmap /etc/postfix/insiders
postmap /etc/postfix/protected_destinations

5. Restart the postfix service.

/etc/init.d/postfix restart

So........... What will be the result??? Only domain.com and anotherdomain.com users can send mails to xyz@domain.com email ID.

Postfix.......... ROCKS.....!!! isn't it???