Настройка Sendmail
SENDMAIL
# install sendmail and sendmail configuration tool yum install sendmail sendmail-cf -y ## ISSUES sendmail can be substituded by postfix sendmail command it can be checked by calling: sendmail -v blah@blah.net and checking if the firs line contains ... ESTMP Postfix If it is, you deal with postfix and it is another subject to discuss, the only thing I can say is that the postfix MTA config is situated in /etc/postfix/ and very similar and simpler that sendmail's one, though I do not understand well either sendmails' nor postfix's ones D: ## CONFIG /etc/mail/ - aliases - access - local-host-names - mailertable - virtusertable - sendmail.mc After editing them always call make to generate .db and .cf files. If you change .mc - sendmail service restart is necessary. В файле virtusertable мы указываем sendmail, куда направлять почту, пришедшую на адреса в доменах определённых в файле local-host-names. http://linux.ufaras.ru/sendmail.html#1.1________
POSTFIX (sendmail)
headercheck(does not work for me with sendmail command)
So if someone stumbles over this like I did: the answer is indeed header_checks and it works as such: Add the following line to /etc/postfix/main.cf: header_checks = regexp:/etc/postfix/header_checks Add the new file /etc/postfix/header_checks with this content: /^To:.*@allowed-domain.com/ DUNNO /^To:.*@/ REDIRECT redirect@example.com Replace allowed-domain.com with the domain your mailserver should still send mails to. Replace redirect@example.com with the email address all other emails should be redirected to. If you need to allow multiple domains, the first line should look like this: /^To:.*@(allowed-domain.com|another-domain.com)/ DUNNO Instead of redirecting you can simple drop all other mails. Replace the second line above with: /^To:.*@/ DISCARD No outgoing mails allowed Explanation: Postfix goes through the mail headers one-by-one. Each header line gets matched against the header_checks file line-by-line. If it matches the first line (To: contains the allowed domain), it skips to the next header line and starts the header checks again from the top. Since no other line will match, this means the mail gets delivered. If it matches the second line (To: contains another external email address), it redirects the mail.
virtual
1. Edit /etc/postfix/virtual This is a plaintext file where you can specify the domains and users to accept mail for. Each virtual domain should begin with a single line containing the domain name. The subsequent lines define addresses at the domain that are deliverable. Mail will be delivered to local usernames on the right side, as demonstrated in the example below. The condition @domain allows you to deliver "all other" mail to the indicated user. You can list multiple domains in this file; just repeat the format demonstrated below. example.com this-text-is-ignored postmaster@example.com postmaster address1@example.com destuser1 address2@example.com destuser2 @example.com destuser1
2. Edit /etc/postfix/main.cf You have to tell postfix where to look for these virtual alias mappings; the appropriate configuration directive is in the main postfix configuration file. This tells postfix to use the db-format (hash) version of your virtual mappings. Note that your system must have db support for this to work; also, the actual db file is not created until you run 'postmap' in step 3. virtual_alias_maps = hash:/etc/postfix/virtual
3. Refresh configuration and mappings Since you've changed main.cf, you should restart the daemon. The second command below updates the virtual mappings; you must run this 'postmap' command when you change your /etc/postfix/virtual file. The 'postmap' command actually creates the hash db file that postfix looks for. postfix reload postmap /etc/postfix/virtual
virtual-regexp
Create /etc/postfix/virtual-regexp with the following content: /.+@.+/ email@gmail.com Edit /etc/postfix/main.cf and add regexp:/etc/postfix/virtual-regexp to the virtual_maps configuration. The end result might look like this in main.cf: virtual_maps = hash:/etc/postfix/virtual, regexp:/etc/postfix/virtual-regexp Build the mapfile by typing: postmap /etc/postfix/virtual-regexp This also requires a virtual.db to exist. If it doesn't create an empty file called virtual and run : touch /etc/postfix/virtual && postmap /etc/postfix/virtual Voila!Postfix look for the first pattern match and applies it.
Comments
Post a Comment