LINUX.ORG.RU
ФорумAdmin

Exim, виртуальные пользователи


0

2

Нужно завести небольшое количество ящиков. Можно это сделать не создавая системных пользователей (/etc/passwd) и без использования sql баз? Что-нибудь вроде текстового файла, в котором имя/адрес и путь к файлу ящика.

Если с exim-ом так не получится, какой mta посоветуете?


Ответ на: комментарий от lodfy

Тут одним разделом не обойтись, в сети полно примеров настройки с использованием баз данных, нужно только сменить место хранения данных с базы на файлы. То что пришло в голову по документации:

6. The Exim run time configuration file

47. Some common configuration settings

34. The plaintext authenticator

У O'Reilly хорошая книжка есть на эту тему. А если найдете у кого-нибудь сервер c ISPmanager то сможете посмотреть примеры файлов конфигурации там.

dGhost ★★★
()

рекомендую «убить» два-три дня и прочитать доку целиком. После этого любая настройка покажется лёгкой. Но если хочешь попробовать свои силы то вот конфиг отвечающий за хранение юзеров в отдельном файле и доставку через dovecot lda(гугли по «dovecot lda»):

#AUTH
dovecot_login:
  driver = dovecot
  public_name = LOGIN
  server_socket = /var/run/dovecot/auth-client
# setting server_set_id might break several headers in mails sent by authenticated smtp. So be careful.
  server_set_id = $auth1

dovecot_plain:
  driver = dovecot
  public_name = PLAIN
  server_socket = /var/run/dovecot/auth-client
  server_set_id = $auth1

#ROUTER
dovecot_user:
  debug_print = "R: dovecot_user for $local_part@$domain"
  driver = accept
  domains = +local_domains
  #condition = COND_LOCAL_SUBMITTER
  condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/passwd}}
  transport = dovecot_delivery
  cannot_route_message = Unknown user

#TRANSPORT
dovecot_delivery:
  driver = pipe
  command = /usr/lib/dovecot/deliver -d $local_part@$domain  -f $sender_address
  # v1.1+: command = /usr/local/libexec/dovecot/deliver -d $local_part@$domain  -f $sender_address -a $original_local_part@$original_domain
  message_prefix =
  message_suffix =
  delivery_date_add
  envelope_to_add
  return_path_add
  log_output
  user = virtmail
  group = virtmail

Сразу скажу, рассказывать как это всё работает построчно не буду, «чтение манов в слух 50$ в час» (c). Просто так на форуме как это всё работает не рассказать, поэтому и доки такие большие что там всё достаточно сложно(и иногда контринтуитивно).

true_admin ★★★★★
()

Очень просто:

Configuring Exim4 under Debian 4 for Virtual Users
Avoiding multiple user accounts for multiple domains and users

This article should help anyone who wants to configure exim4 to accept mail for multiple virtual domains and virtual users.
There are plenty of articles describing how to set up exim with user authentication from a database such as mysql, etc. The goal here
was to set up exim so that the list of users and domains for which it would accept emails are provided in plain text files, and that the system stores the emails in maildir format. The system being used is Debian 4 stable (aka etch).

1. Install exim and make sure it has split configuration files

I am going to assume you already have a working exim installed. This should be a simple case of apt-get install exim4. There are plenty of guides already covering this. During installation it will prompt you whether or not you want split configuration files. If you are already beyond that point you can re-run the configuration script with the command dpkg-reconfigure exim4-config. More details on this are available elsewhere on the web.

2. Create a 'virtual home' directory for all the domains and users


It is important that user mail owns these directories, so that exim can write to them and create the necessary sub-directories on the fly.



mkdir /home/virtualusers/

mkdir /home/virtualusers/example1.com

mkdir /home/virtualusers/example2.net

mkdir /home/virtualusers/example3.org




3. Make sure user 'mail' owns everything

This is because we will be getting exim to create the sub-directories used in the maildir format on-the-fly.



chown -R mail:mail /home/virtualusers



4. Create a directory/file structure to hold all of our virtual domain names and email addresses

In the virtual_domains/ directory will be one file per domain that we will accept mail for. In this file will be one username per line. For example:



mkdir /etc/virtual_domains

echo «alice» > /etc/virtual_domains/example1.com

echo «andrew» >> /etc/virtual_domains/example1.com

echo «betty» > /etc/virtual_domains/example2.net

echo «bob» >> /etc/virtual_domains/example2.net

echo «cecilia» > /etc/virtual_domains/example3.org

echo «charlie» >> /etc/virtual_domains/example3.org



In this example, the resulting email addresses we are accepting email for would be:
alice@example1.com
andrew@example1.com
betty@example2.net
bob@example2.net
cecilia@example3.org
charlie@example3.org

5. Modify exim's router configuration


You should have a series of files in /etc/exim4/conf.d/router/. These are processed in their numerical order. You will need to create one. The filename itself is unimportant, except for the number part that will specify the order in which these routing rules are combined and hence processed. In this case, I wanted my virtual users to be checked ahead of any local users (as I have both virtual and physical users on my box), so I named the file 899_virtual_user. If I wanted mail to be routed to physical users first, and check virtual users if not matched, I would have named it 901_virtual_user.

The contents of this file are:



my_domains:

driver = accept

domains = dsearch;/etc/virtual_domains

local_parts = lsearch;/etc/virtual_domains/$domain

transport = my_mailboxes

no_more


The first line is just a name for this section and is unimportant, as long as it is unique.
The third line says to search the /etc/virtual_domains/ directory for names of files matching the domain we are receiving an email for.
The 4th line says to look for the local part (ie the email address part preceeding the @) in the file /etc/virtual_domains/<domain_name>. Note that $domain is a substitution parameter, it will be replaced with the domain we are trying to receive an email for. Similarly, $local_part would be substituted with the email address part preceeding the @.
The 5th line says that, if a match is found, deliver (ie transport) the email according to the transport rules named 'my_mailboxes'

6. Modify exim's transport configuration


You should have a series of files in /etc/exim4/conf.d/transport/. These are processed in their numerical order, however the order is unimportant. In this example I called my file 29_virtual_users. Its contents look like this:



my_mailboxes:

driver = appendfile

user = mail

maildir_format = true

directory = /home/virtualmail/$domain/$local_part

create_directory

delivery_date_add

envelope_to_add

return_path_add

group = mail

mode = 0600



The first line is the name referenced in our router section.
The 2nd line is a standard directive.
The 3rd line tells exim to create any new files and folders as user mail.
Line 4 says to use the maildir format. You could use the mbox format by omitting this line and changing the directive on the next line from directory= to file=
Line 5 specifies the directory where the emails will be stored. $domain gets substituted for the domain name (the portion after the @) and $local_part gets substituted for the user name (the portion of the email address before the @).
The remainining lines should be fairly self-explanatory.

7. Re-start exim

This is achieved with /etc/init.d/exim4 restart. Try sending some emails to your machine and test the configuration. If it fails then check over these details and the system logs carefully.

sun-lsd
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.