Howto install and configure Postfix Mail Server on Fedora 18

Howto install and configure Postfix Mail Server on Fedora 18

install configure postfix Fedora 18

 

1. Install postfix by yum:

[root@fedora18 ~]# yum -y install postfix
Loaded plugins: langpacks, presto, refresh-packagekit
updates/group_gz | 368 kB 00:15
updates/primary_db | 7.1 MB 02:06
Resolving Dependencies
–> Running transaction check
—> Package postfix.i686 2:2.9.6-3.fc18 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
postfix i686 2:2.9.6-3.fc18 updates 2.5 M

Transaction Summary
================================================================================
Install 1 Package

Total download size: 2.5 M
Installed size: 12 M
Downloading Packages:
warning: /var/cache/yum/i386/18/updates/packages/postfix-2.9.6-3.fc18.i686.rpm: Header V3 RSA/SHA256 Signature, key ID de7f38bd: NOKEY
Public key for postfix-2.9.6-3.fc18.i686.rpm is not installed
postfix-2.9.6-3.fc18.i686.rpm | 2.5 MB 00:26
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-i386
Importing GPG key 0xDE7F38BD:
Userid : “Fedora (18) <fedora@fedoraproject.org>”
Fingerprint: 7efb 8811 dd11 e380 b679 fced ff01 125c de7f 38bd
Package : fedora-release-18-1.noarch (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-i386
Running Transaction Check
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 2:postfix-2.9.6-3.fc18.i686 1/1
Verifying : 2:postfix-2.9.6-3.fc18.i686 1/1

Installed:
postfix.i686 2:2.9.6-3.fc18

Complete!

2. Edit the postfix config file:

[root@fedora18 ~]# vi /etc/postfix/main.cf

1 # Global Postfix configuration file. This file lists only a subset
2 # of all parameters. For the syntax, and for a complete parameter
3 # list, see the postconf(5) manual page (command: “man 5 postconf”).
4 #
5 # For common configuration examples, see BASIC_CONFIGURATION_README
6 # and STANDARD_CONFIGURATION_README. To find these documents, use
7 # the command “postconf html_directory readme_directory”, or go to
8 # http://www.postfix.org/.
9 #
10 # For best results, change no more than 2-3 parameters at a time,
11 # and test if Postfix still works after every change.
12
13 # SOFT BOUNCE
14 #
15 # The soft_bounce parameter provides a limited safety net for
16 # testing. When soft_bounce is enabled, mail will remain queued that
17 # would otherwise bounce. This parameter disables locally-generated
18 # bounces, and prevents the SMTP server from rejecting mail permanently
19 # (by changing 5xx replies into 4xx replies). However, soft_bounce
20 # is no cure for address rewriting mistakes or mail routing mistakes.
21 #
22 #soft_bounce = no
23
24 # LOCAL PATHNAME INFORMATION
25 #
26 # The queue_directory specifies the location of the Postfix queue.
27 # This is also the root directory of Postfix daemons that run chrooted.
28 # See the files in examples/chroot-setup for setting up Postfix chroot
29 # environments on different UNIX systems.
30 #
31 queue_directory = /var/spool/postfix
32
33 # The command_directory parameter specifies the location of all
34 # postXXX commands.
35 #
36 command_directory = /usr/sbin
37
38 # The daemon_directory parameter specifies the location of all Postfix
39 # daemon programs (i.e. programs listed in the master.cf file). This
40 # directory must be owned by root.
41 #
42 daemon_directory = /usr/libexec/postfix

43
44 # The data_directory parameter specifies the location of Postfix-writable
45 # data files (caches, random numbers). This directory must be owned
46 # by the mail_owner account (see below).
47 #
48 data_directory = /var/lib/postfix
49
50 # QUEUE AND PROCESS OWNERSHIP
51 #
52 # The mail_owner parameter specifies the owner of the Postfix queue
53 # and of most Postfix daemon processes. Specify the name of a user
54 # account THAT DOES NOT SHARE ITS USER OR GROUP ID WITH OTHER ACCOUNTS
55 # AND THAT OWNS NO OTHER FILES OR PROCESSES ON THE SYSTEM. In
56 # particular, don’t specify nobody or daemon. PLEASE USE A DEDICATED
57 # USER.
58 #
59 mail_owner = postfix
60
61 # The default_privs parameter specifies the default rights used by
62 # the local delivery agent for delivery to external file or command.
63 # These rights are used in the absence of a recipient user context.
64 # DO NOT SPECIFY A PRIVILEGED USER OR THE POSTFIX OWNER.
65 #
66 #default_privs = nobody
67
68 # INTERNET HOST AND DOMAIN NAMES
69 #
70 # The myhostname parameter specifies the internet hostname of this
71 # mail system. The default is to use the fully-qualified domain name
72 # from gethostname(). $myhostname is used as a default value for many
73 # other configuration parameters.
74 #
75 myhostname = mail.ithelpblog.com
76 #myhostname = virtual.domain.tld
77
78 # The mydomain parameter specifies the local internet domain name.
79 # The default is to use $myhostname minus the first component.
80 # $mydomain is used as a default value for many other configuration
81 # parameters.
82 #
83 mydomain = ithelpblog.com
84
85 # SENDING MAIL

86 #
87 # The myorigin parameter specifies the domain that locally-posted
88 # mail appears to come from. The default is to append $myhostname,
89 # which is fine for small sites. If you run a domain with multiple
90 # machines, you should (1) change this to $mydomain and (2) set up
91 # a domain-wide alias database that aliases each user to
92 # user@that.users.mailhost.
93 #
94 # For the sake of consistency between sender and recipient addresses,
95 # myorigin also specifies the default domain name that is appended
96 # to recipient addresses that have no @domain part.
97 #
98 #myorigin = $myhostname
99 myorigin = $mydomain
100
101 # RECEIVING MAIL
102
103 # The inet_interfaces parameter specifies the network interface
104 # addresses that this mail system receives mail on. By default,
105 # the software claims all active interfaces on the machine. The
106 # parameter also controls delivery of mail to user@[ip.address].
107 #
108 # See also the proxy_interfaces parameter, for network addresses that
109 # are forwarded to us via a proxy or network address translator.
110 #
111 # Note: you need to stop/start Postfix when this parameter changes.
112 #
113 #inet_interfaces = all
114 #inet_interfaces = $myhostname
115 #inet_interfaces = $myhostname, localhost
116 inet_interfaces = all
117
118 # Enable IPv4, and IPv6 if supported
119 inet_protocols = all
120
121 # The proxy_interfaces parameter specifies the network interface
122 # addresses that this mail system receives mail on by way of a
123 # proxy or network address translation unit. This setting extends
124 # the address list specified with the inet_interfaces parameter.
125 #
126 # You must specify your proxy/NAT addresses when your system is a
127 # backup MX host for other domains, otherwise mail delivery loops
128 # will happen when the primary MX host is down.

129 #
130 #proxy_interfaces =
131 #proxy_interfaces = 1.2.3.4
132
133 # The mydestination parameter specifies the list of domains that this
134 # machine considers itself the final destination for.
135 #
136 # These domains are routed to the delivery agent specified with the
137 # local_transport parameter setting. By default, that is the UNIX
138 # compatible delivery agent that lookups all recipients in /etc/passwd
139 # and /etc/aliases or their equivalent.
140 #
141 # The default is $myhostname + localhost.$mydomain. On a mail domain
142 # gateway, you should also include $mydomain.
143 #
144 # Do not specify the names of virtual domains – those domains are
145 # specified elsewhere (see VIRTUAL_README).
146 #
147 # Do not specify the names of domains that this machine is backup MX
148 # host for. Specify those names via the relay_domains settings for
149 # the SMTP server, or use permit_mx_backup if you are lazy (see
150 # STANDARD_CONFIGURATION_README).
151 #
152 # The local machine is always the final destination for mail addressed
153 # to user@[the.net.work.address] of an interface that the mail system
154 # receives mail on (see the inet_interfaces parameter).
155 #
156 # Specify a list of host or domain names, /file/name or type:table
157 # patterns, separated by commas and/or whitespace. A /file/name
158 # pattern is replaced by its contents; a type:table is matched when
159 # a name matches a lookup key (the right-hand side is ignored).
160 # Continue long lines by starting the next line with whitespace.
161 #
162 # See also below, section “REJECTING MAIL FOR UNKNOWN LOCAL USERS”.
163 #
164 mydestination = $myhostname, localhost.$mydomain, localhost,$mydomain
165 #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
166 #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
167 # mail.$mydomain, www.$mydomain, ftp.$mydomain
168
169 # REJECTING MAIL FOR UNKNOWN LOCAL USERS
170 #
171 # The local_recipient_maps parameter specifies optional lookup tables

172 # with all names or addresses of users that are local with respect
173 # to $mydestination, $inet_interfaces or $proxy_interfaces.
174 #
175 # If this parameter is defined, then the SMTP server will reject
176 # mail for unknown local users. This parameter is defined by default.
177 #
178 # To turn off local recipient checking in the SMTP server, specify
179 # local_recipient_maps = (i.e. empty).
180 #
181 # The default setting assumes that you use the default Postfix local
182 # delivery agent for local delivery. You need to update the
183 # local_recipient_maps setting if:
184 #
185 # – You define $mydestination domain recipients in files other than
186 # /etc/passwd, /etc/aliases, or the $virtual_alias_maps files.
187 # For example, you define $mydestination domain recipients in
188 # the $virtual_mailbox_maps files.
189 #
190 # – You redefine the local delivery agent in master.cf.
191 #
192 # – You redefine the “local_transport” setting in main.cf.
193 #
194 # – You use the “luser_relay”, “mailbox_transport”, or “fallback_transport”
195 # feature of the Postfix local delivery agent (see local(8)).
196 #
197 # Details are described in the LOCAL_RECIPIENT_README file.
198 #
199 # Beware: if the Postfix SMTP server runs chrooted, you probably have
200 # to access the passwd file via the proxymap service, in order to
201 # overcome chroot restrictions. The alternative, having a copy of
202 # the system passwd file in the chroot jail is just not practical.
203 #
204 # The right-hand side of the lookup tables is conveniently ignored.
205 # In the left-hand side, specify a bare username, an @domain.tld
206 # wild-card, or specify a user@domain.tld address.
207 #
208 #local_recipient_maps = unix:passwd.byname $alias_maps
209 #local_recipient_maps = proxy:unix:passwd.byname $alias_maps
210 #local_recipient_maps =
211
212 # The unknown_local_recipient_reject_code specifies the SMTP server
213 # response code when a recipient domain matches $mydestination or
214 # ${proxy,inet}_interfaces, while $local_recipient_maps is non-empty

215 # and the recipient address or address local-part is not found.
216 #
217 # The default setting is 550 (reject mail) but it is safer to start
218 # with 450 (try again later) until you are certain that your
219 # local_recipient_maps settings are OK.
220 #
221 unknown_local_recipient_reject_code = 550
222
223 # TRUST AND RELAY CONTROL
224
225 # The mynetworks parameter specifies the list of “trusted” SMTP
226 # clients that have more privileges than “strangers”.
227 #
228 # In particular, “trusted” SMTP clients are allowed to relay mail
229 # through Postfix. See the smtpd_recipient_restrictions parameter
230 # in postconf(5).
231 #
232 # You can specify the list of “trusted” network addresses by hand
233 # or you can let Postfix do it for you (which is the default).
234 #
235 # By default (mynetworks_style = subnet), Postfix “trusts” SMTP
236 # clients in the same IP subnetworks as the local machine.
237 # On Linux, this does works correctly only with interfaces specified
238 # with the “ifconfig” command.
239 #
240 # Specify “mynetworks_style = class” when Postfix should “trust” SMTP
241 # clients in the same IP class A/B/C networks as the local machine.
242 # Don’t do this with a dialup site – it would cause Postfix to “trust”
243 # your entire provider’s network. Instead, specify an explicit
244 # mynetworks list by hand, as described below.
245 #
246 # Specify “mynetworks_style = host” when Postfix should “trust”
247 # only the local machine.
248 #
249 #mynetworks_style = class
250 #mynetworks_style = subnet
251 #mynetworks_style = host
252
253 # Alternatively, you can specify the mynetworks list by hand, in
254 # which case Postfix ignores the mynetworks_style setting.
255 #
256 # Specify an explicit list of network/netmask patterns, where the
257 # mask specifies the number of bits in the network part of a host

258 # address.
259 #
260 # You can also specify the absolute pathname of a pattern file instead
261 # of listing the patterns here. Specify type:table for table-based lookups
262 # (the value on the table right-hand side is not used).
263 #
264 mynetworks = 192.168.1.0/28, 127.0.0.0/8
265 #mynetworks = $config_directory/mynetworks
266 #mynetworks = hash:/etc/postfix/network_table
267
268 # The relay_domains parameter restricts what destinations this system will
269 # relay mail to. See the smtpd_recipient_restrictions description in
270 # postconf(5) for detailed information.
271 #
272 # By default, Postfix relays mail
273 # – from “trusted” clients (IP address matches $mynetworks) to any destination,
274 # – from “untrusted” clients to destinations that match $relay_domains or
275 # subdomains thereof, except addresses with sender-specified routing.
276 # The default relay_domains value is $mydestination.
277 #
278 # In addition to the above, the Postfix SMTP server by default accepts mail
279 # that Postfix is final destination for:
280 # – destinations that match $inet_interfaces or $proxy_interfaces,
281 # – destinations that match $mydestination
282 # – destinations that match $virtual_alias_domains,
283 # – destinations that match $virtual_mailbox_domains.
284 # These destinations do not need to be listed in $relay_domains.
285 #
286 # Specify a list of hosts or domains, /file/name patterns or type:name
287 # lookup tables, separated by commas and/or whitespace. Continue
288 # long lines by starting the next line with whitespace. A file name
289 # is replaced by its contents; a type:name table is matched when a
290 # (parent) domain appears as lookup key.
291 #
292 # NOTE: Postfix will not automatically forward mail for domains that
293 # list this system as their primary or backup MX host. See the
294 # permit_mx_backup restriction description in postconf(5).
295 #
296 #relay_domains = $mydestination
297
298 # INTERNET OR INTRANET
299
300 # The relayhost parameter specifies the default host to send mail to

…………………………………………………………………………………………………………………………………………………………………………………………………………………………….

415 # mailbox file is /var/spool/mail/user or /var/mail/user. Specify
416 # “Maildir/” for qmail-style delivery (the / is required).
417 #
418 #home_mailbox = Mailbox
419 home_mailbox = Maildir/   #uncomment (use Maildir
420
421 # The mail_spool_directory parameter specifies the directory where
422 # UNIX-style mailboxes are kept. The default setting depends on the
423 # system type.
424 #
425 #mail_spool_directory = /var/mail
426 #mail_spool_directory = /var/spool/mail
427
428 # The mailbox_command parameter specifies the optional external
429 # command to use instead of mailbox delivery. The command is run as
430 # the recipient with proper HOME, SHELL and LOGNAME environment settings.
431 # Exception: delivery for root is done as $default_user.
432 #
433 # Other environment variables of interest: USER (recipient username),
434 # EXTENSION (address extension), DOMAIN (domain part of address),
435 # and LOCAL (the address localpart).
436 #
437 # Unlike other Postfix configuration parameters, the mailbox_command
438 # parameter is not subjected to $parameter substitutions. This is to
439 # make it easier to specify shell syntax (see example below).
440 #
441 # Avoid shell meta characters because they will force Postfix to run
442 # an expensive shell process. Procmail alone is expensive enough.
443 #
444 # IF YOU USE THIS TO DELIVER MAIL SYSTEM-WIDE, YOU MUST SET UP AN
445 # ALIAS THAT FORWARDS MAIL FOR ROOT TO A REAL USER.
446 #
447 #mailbox_command = /some/where/procmail
448 #mailbox_command = /some/where/procmail -a “$EXTENSION”
449
450 # The mailbox_transport specifies the optional transport in master.cf
451 # to use after processing aliases and .forward files. This parameter
452 # has precedence over the mailbox_command, fallback_transport and
453 # luser_relay parameters.
454 #
455 # Specify a string of the form transport:nexthop, where transport is
456 # the name of a mail delivery transport defined in master.cf. The

……………………………………………………………………………………………………………
……………………………………………………………………………………………………………

548 header_checks = regexp:/etc/postfix/header_checks\  # uncomment
549 body_checks = regexp:/etc/postfix/body_checks  # add the line
550
551 # FAST ETRN SERVICE
552 #
553 # Postfix maintains per-destination logfiles with information about
554 # deferred mail, so that mail can be flushed quickly with the SMTP
555 # “ETRN domain.tld” command, or by executing “sendmail -qRdomain.tld”.
556 # See the ETRN_README document for a detailed description.
557 #
558 # The fast_flush_domains parameter controls what destinations are
559 # eligible for this service. By default, they are all domains that
560 # this server is willing to relay mail to.
561 #
562 #fast_flush_domains = $relay_domains
563
564 # SHOW SOFTWARE VERSION OR NOT
565 #
566 # The smtpd_banner parameter specifies the text that follows the 220
567 # code in the SMTP server’s greeting banner. Some people like to see
568 # the mail version advertised. By default, Postfix shows no version.
569 #
570 # You MUST specify $myhostname at the start of the text. That is an
571 # RFC requirement. Postfix itself does not care.
572 #
573 #smtpd_banner = $myhostname ESMTP $mail_name
574 smtpd_banner = $myhostname ESMTP
575
576 # PARALLEL DELIVERY TO THE SAME DESTINATION
577 #
578 # How many parallel deliveries to the same user or domain? With local
579 # delivery, it does not make sense to do massively parallel delivery
580 # to the same user, because mailbox updates must happen sequentially,
581 # and expensive pipelines in .forward files can cause disasters when
582 # too many are run at the same time. With SMTP deliveries, 10
583 # simultaneous connections to the same domain could be sufficient to
584 # raise eyebrows.
585 #
586 # Each message delivery transport has its XXX_destination_concurrency_limit
587 # parameter. The default is $default_destination_concurrency_limit for
588 # most delivery transports. For the local delivery agent the default is 2.

………………………………………………………………………………………………………….

# add at the last line

# limit an email size 10M

message_size_limit = 10485760

# limit mailbox 1G

mailbox_size_limit = 1073741824

# for SMTP-Auth settings

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_client_restrictions = permit_mynetworks,reject_unknown_client,permit
smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject

3. Config header_checks for postfix:

[root@fedora18 ~]# vi /etc/postfix/header_checks
1 # HEADER_CHECKS(5) HEADER_CHECKS(5)
2 # add at the head
3 # for example, reject from “example.com”
4 /^From:.*@example\.com/ REJECT

4. Config body_checks for postfix:

[root@fedora18 ~]# vi /etc/postfix/body_checks
# for example, reject if “example.com” is in mail body
/^(|[^>].*)example.com/ REJECT

5. Stop and disable sendmail and set postfix as default MTA:

[root@fedora18 ~]# systemctl stop sendmail.service
[root@fedora18 ~]# systemctl disable sendmail.service
rm ‘/etc/systemd/system/multi-user.target.wants/sm-client.service’
rm ‘/etc/systemd/system/multi-user.target.wants/sendmail.service’
[root@fedora18 ~]# alternatives –config mta

There are 2 programs which provide ‘mta’.

Selection Command
———————————————–
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.postfix

Enter to keep the current selection[+], or type selection number: 2 # Set postfix at default MTA

6. Start postfix and set postfix start at boot time:

[root@fedora18 ~]# systemctl start postfix.service
[root@fedora18 ~]# systemctl enable postfix.service

That’s all . Thanks for using ithelpblog.com

Tags:  

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>