Link to home
Start Free TrialLog in
Avatar of XK8ER
XK8ERFlag for United States of America

asked on

Dovecot and Postfix - mail permission issue

Hello,
I have installed Dovecot and Postfix.. I am able to send and receive email.
all works good but for some reason I have to change email persmission to 777 or change ownership to "onecatch" or "twocatch" users.. too be able to access the email with SquirrelMail..
I am running Centos v6.4 and I added two new users.. to be able to login with SquirrelMail

adduser onecatch
adduser twocatch

I have to do this each time I want to check emails
/bin/chown -R onecatch:onecatch /home/virtual/email/onecatch
/bin/chown -R twocatch:twocatch /home/virtual/email/twocatch

>dovecot.conf
protocols = imap pop3 lmtp

dict {
  #quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
  #expire = sqlite:/etc/dovecot/dovecot-dict-sql.conf.ext
}

!include conf.d/*.conf

mail_location = maildir:/home/virtual/email/%u/

Open in new window

>main.cf
## These settings differers from the default config ##
myhostname = mysite.net
mail_owner = postfix
mydomain = mysite.net
myorigin = $mydomain
inet_interfaces = all
inet_protocols = all
mydestination = localhost, mail.localdomain, localhost.localdomain, localdomain
unknown_local_recipient_reject_code = 550
in_flow_delay = 1s
home_mailbox = Maildir/
mail_spool_directory = /home/virtual/email
smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)

## The following is added to the config ##
local_transport = virtual
virtual_mailbox_domains = /home/virtual/email/my_domains
virtual_mailbox_base = /home/virtual/email
virtual_mailbox_maps = hash:/home/virtual/email/my_virtual
virtual_minimum_uid = 100
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000


smtpd_helo_required = yes
disable_vrfy_command = yes
smtpd_recipient_restrictions =
        reject_unauth_pipelining,
        permit_sasl_authenticated,
        permit_mynetworks,
        reject_invalid_hostname, reject_non_fqdn_hostname,
        reject_non_fqdn_sender, reject_non_fqdn_recipient,
        reject_unknown_sender_domain, reject_unknown_recipient_domain,
        reject_unauth_destination, 
        permit
smtpd_data_restrictions = reject_unauth_pipelining, permit

Open in new window

>my_domains
mysite.net
stayathomemon.net
adoption.net
fertility.net
google.net

Open in new window

>my_virtual
@stayathomemon.net		onecatch/
@adoption.net				onecatch/

@mysite.net             		twocatch/
@google.net            			twocatch/

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of DrDamnit
DrDamnit
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Additionally, you may consider reading this article:
http://learnlinuxonline.com/servers/how-setup-linux-mail-server-debian-ubuntu

It has step by step instructions on setting up a mail server exactly as you're attempting to get working. While it is for Debian / Ubuntu users, the differences are minimal. Most notably the package manager you use is yum, while Debian / Ubuntu uses apt. And, some files may be in slightly different places, but a google search or two should clarify.

Compare the steps in the article to the steps you have done in your setup to see what's different.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of XK8ER

ASKER

maybe I am going with the wrong approach or I am confused..

I do this from the shell..

adduser bob
adduser mike

then I login using SquirrelMail or the beautiful RoundCube thanks it4soho =)

I see new created files from
"/home/virtual/email/bob"
"/home/virtual/email/mike"

owned by "bob" or by "mike"
Avatar of XK8ER

ASKER

maybe there is a different way to add virtual users?

how can i do this the right way of setup i've been trying to figure it out for the past 3 days now..
@Dan - where did you "differ" from me? We seem to be on the exact same page...

@XK8ER -
If you use the guide I gave you, you can then install postfixadmin, which gives you a GUI to add virtual domains, virtual users, the whole nine yards.

Screenshots:
http://postfixadmin.sourceforge.net/screenshots/

Main Page:
http://postfixadmin.sourceforge.net/
Avatar of XK8ER

ASKER

DrDamnit, I totally understand but that defeats the purpose of learning how to do it from shell.. I think that I finally figure it out..

I deleted the users by doing this

userdel -r bob
userdel -r mike

then added something like this >passwd

bob:{PLAIN}Temp123
mike:{PLAIN}Temp123


now all incoming mail and newly created files and everything stays the same owned by "vmail" instead of bob or mike..

#dovecot.conf
protocols = imap pop3 lmtp

!include conf.d/*.conf

log_path = /home/virtual/email/dovecot.log
info_log_path = /home/virtual/email/dovecot-info.log

# Disable SSL for now.
ssl = no # v1.2+, for older versions use: ssl_disable = yes
disable_plaintext_auth = no

mail_location = maildir:/home/virtual/email/%u/
#mail_location = maildir:~/Maildir

# Authentication configuration:
auth_verbose = yes

auth_mechanisms = plain
passdb {
  driver = passwd-file
  args = /home/virtual/email/passwd
}
userdb {
  driver = static
  args = uid=vmail gid=vmail home=/home/virtual/email/%u/
}

Open in new window

I didn't realize doing this manually via the shell was part of the requirements. This isn't a production system?

Also, did you edit /etc/passwd manually? Editing that file manually and storing passwords in plaintext are generally not advised if this system is going to be on the internet sending and receiving mail.

At any rate, do you have it working now?
Avatar of XK8ER

ASKER

yes its working now but I was reading dovecot and the passwords can be stored as hashed so that would be the only thing left to do instead of plain text..

source: http://wiki2.dovecot.org/HowTo/SimpleVirtualInstall
Avatar of XK8ER

ASKER

changed to
disable_plaintext_auth = yes

and switched to password data

bob:{SSHA}5ZB782OPs+WYp/osdsEe+mKru5lhxpuM
mike:{SSHA}5ZB782OPs+WYp/osdsEe+mKru5lhxpuM

thats pretty much it.. everything else seems to be up and running nicely!
Glad you got it working. If there's nothing else, don't forget to close the question.
Avatar of XK8ER

ASKER

thanks a lot guys