[MacPorts] howto/SetupPostfix modified

MacPorts noreply at macports.org
Fri Jun 17 18:02:47 PDT 2011


Changed page "howto/SetupPostfix" by macintosh at mathiesen.info from 90.184.12.220*
Page URL: <https://trac.macports.org/wiki/howto/SetupPostfix>
Diff URL: <https://trac.macports.org/wiki/howto/SetupPostfix?action=diff&version=16>
Revision 16

-------8<------8<------8<------8<------8<------8<------8<------8<--------
Index: howto/SetupPostfix
=========================================================================
--- howto/SetupPostfix (version: 15)
+++ howto/SetupPostfix (version: 16)
@@ -9,7 +9,7 @@
 
 This How-to is part of the [wiki:howto/SetupFetchmail Fetchmail] ->  [wiki:howto/SetupPostfix Postfix] -> [wiki:howto/SetupDovecot Dovecot] advanced e-Mail set-up.
 
-[wikipedia:Postfix_%28software%29 Postfix] is a [wikipedia:Mail_transfer_agent mail transfer agent] which can distribute your in and outbound mail. The set-up described here will distribute inbound mail to a [wikipedia:Dovecot_%28software%29 Dovecot]  [wikipedia:Internet_Message_Access_Protocol IMAP] server and outbound mail to an [wikipedia:Internet_service_provider internet service provider].
+[wikipedia:Postfix_%28software%29 Postfix] is a [wikipedia:Mail_transfer_agent mail transfer agent] which can distribute your in- and out-bound mail. The set-up described here will distribute inbound mail to a [wikipedia:Dovecot_%28software%29 Dovecot]  [wikipedia:Internet_Message_Access_Protocol IMAP] server and outbound mail to an [wikipedia:Internet_service_provider internet service provider].
 
 Distribution of E-Mail directly to the end receiver is one of the joys of the internet which has been destroyed by [wikipedia:E-mail_spam SPAM]. 
 
@@ -27,64 +27,154 @@
 
 === Postfix ===
 
-Install postfix with:
+We'll want everything, so use the following script to get it:
 
 {{{
-port install postfix +tls +ldap
+#!/macports/bin/bash
+
+declare -a toInstall
+toInstall=( \
+            postfix+dovecot_sasl+tls+pcre+mysql5+postgresql90 postgrey \
+            dovecot2+ldap+mysql5+postgresql90 dovecot2-sieve \
+            fetchmail \
+            squirrelmail \
+         )
+
+for doInstall in ${toInstall[@]}
+do
+    (sudo port install ${doInstall//+/ +}) ; wait
+done
+
+exit
 }}}
-
-or - alternatively - use the postfix which comes pre installed with Max OSX.
 
 == Configuration ==
 
-Most of the postfix configuration is done in the [attachment:main.cf] file which you find either in {{{/opt/local/etc/postfix}}} (macports) or {{{/etc/postfix}}} (OSX).
+The configuration is done several files of which we'll need at least three:
+ 1. master.cf
+ 1. main.cf
+ 1. alias
+
+=== Step 0: '''master.cf''' ===
+
+Don't mess with this file at all at this point in the process !!!
 
 === Step 1: '''setup main.cf''' ===
 
-==== set hostname and domain ====
-
-Search for {{{my_computer}}} and {{{my_domain}}} in {{{main.cf}}} and replace them with the domain name and computer name of your computer. You can find them out with the {{{hostname}}} command. 
-
-The following lines need attention:
+You'll find all the default settings in '''/macports/etc/postfix/main.cf.default''' - all of these settings are explained in some depth here [http://www.postfix.org/postconf.5.html postconf.5] or {{{man 5 postconf}}}.  You'll find a sample primary configuration in '''/macports/etc/postfix/main.cf.sample'''. '''main.cf.sample''' is extensively commented, but to get an overview of the which setting are present in the file execute this command:
 
 {{{
-myhostname = my_computer.local
-mydomain = my_domain.com
-mydestination = localhost,localhost.my_domain.com,my_computer,my_computer.local,my_computer.my_domain.com
-masquerade_domains = my_domain.com
+grep ' =' /macports/etc/postfix/main.cf.default
 }}}
 
-Note: if you don't use an domain name apart from {{{.local}}} then you can remove the duplicate.
+We'll change some of them in the following, but a lot of them has to be left alone and are not to be messed with under most circumstances as you'll completely mess up your configuration if you do so - you have been duly warned !
 
-==== set relayhost ====
+==== sending email ====
 
-Your outbound mail needs to go to a relayhost as most of us can't send e-mail directly any more. My relayhost is {{{smtp.my_domain.com}}} this does not need to be for you.
+Let's start by getting postfix to send email from the local computer. I'm assuming that you'll be running a webserver that'll need to send and receive eg confirmation email as well as receiving the general email for one or more domains.
 
-The following lines need attention:
+The {{{hostname}}} command will give you an a value for what your computer is called, but this is in many cases not a useful name. If you get your IP-number or DNS-settings from a DHCP-server the rDNS-name will be your hostname eg '''4604ds1-ynoe.2.fullrate.dk''' and that's not what you in most cases want your recipients to see as the sending computer. Furthermore, {{{hostname}}} only reflects what the first interface as listed in the Network Preferences Pane is called.
 
 {{{
-relayhost = [smtp.my_domain.com]
+# The myhostname parameter specifies the internet hostname of this
+# mail system. The default is to use the fully-qualified domain name
+# from gethostname(). $myhostname is used as a default value for many
+# other configuration parameters.
+#
+#myhostname = host.domain.tld
+#myhostname = virtual.domain.tld
+myhostname  = computer.example.com
+
+# The mydomain parameter specifies the local internet domain name.
+# The default is to use $myhostname minus the first component.
+# $mydomain is used as a default value for many other configuration
+# parameters.
+#
+#mydomain = domain.tld
+#mydomain = domain.tld
+mydomain  = example.com
+
+# The myorigin parameter specifies the domain that locally-posted
+# mail appears to come from. The default is to append $myhostname,
+#
+#myorigin = $myhostname
+#myorigin = $mydomain
+#myorigin = $myhostname
+#myorigin = $mydomain
+myorigin  = $mydomain
 }}}
 
-==== /usr <-> /opt/local ====
+Setting '''inet_interfaces''' to '''localhost''' effectively blocks receipt of email. We'll change this setting when we look at receiving email.
+{{{
+# The inet_interfaces parameter specifies the network interface
+# addresses that this mail system receives mail on.  By default,
+# the software claims all active interfaces on the machine. The
+# parameter also controls delivery of mail to user@[ip.address].
+#
+#inet_interfaces = all
+#inet_interfaces = $myhostname
+#inet_interfaces = $myhostname, localhost
+inet_interfaces  = localhost
+}}}
 
-Depending on which version of postfix (osx vs. macports) you use you have to change all lines containing {{{/usr}}} to {{{/opt/local}}}.
-The MacPorts installation automatically changes these in main.cf to {{{/opt/local}}}.
+This blocks other computers from relaying email through your computer
+{{{
+#mynetworks_style = class
+#mynetworks_style = subnet
+#mynetworks_style = host
+mynetworks_style  = host
+}}}
 
-==== /private <-> /opt/local ====
+Your outbound mail might need to go through a relayhost as most of us can't send e-mail directly anymore. Due to spam from bot-nets many ISPs block port 25 in their firewall. Mostly it'll be '''smtp.ISP-name.tld''' or something like that, but you ought to be able to find it on the ISPs website. This is also the setting you use in Mail.app for sending email.
+{{{
+#relayhost = $mydomain
+#relayhost = [gateway.my.domain]
+#relayhost = [mailserver.isp.tld]
+#relayhost = uucphost
+#relayhost = [an.ip.add.ress]
+relayhost  = [smtp.isp-name.com]
+}}}
 
-Depending on which version of postfix (osx vs. macports) you use you have to change all lines containing {{{/private}}} to {{{/opt/local}}}.
-The MacPorts installation automatically changes these in main.cf to {{{/opt/local}}}.
 
-==== verify your changes ====
+=== Step 2: '''setup of aliases''' ===
 
-Use "diff" to  list the differences between the original (main.cf.sample) and the current main.cf file.
+We'll need at least one entry in the aliases database. If aliases.db isn't present, the postfix master will start, but upon the first activity you'll get repeated lines of this kind :
+{{{
+Jun 17 23:03:52 Pro17 postfix/master[262]: warning: /macports/libexec/postfix/smtpd: bad command startup -- throttling
+Jun 17 23:04:52 Pro17 postfix/smtpd[17162]: fatal: open database /macports/etc/postfix/aliases.db: No such file or directory
+Jun 17 23:04:53 Pro17 postfix/master[262]: warning: process /macports/libexec/postfix/smtpd pid 17162 exit status 1
+}}}
 
-Note that "main.cf.default" lists all possible parameters and their defaults for the "cf" file.
+These are lines in main.cf of interest:
+{{{
+#alias_maps = dbm:/etc/aliases
+#alias_maps = hash:/etc/aliases
+#alias_maps = hash:/etc/aliases, nis:mail.aliases
+#alias_maps = netinfo:/aliases
+#alias_database = dbm:/etc/aliases
+#alias_database = dbm:/etc/mail/aliases
+#alias_database = hash:/etc/aliases
+#alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases
+}}}
 
-=== Step 2: '''setup relay passwords''' ===
+At present, we'll simply go with the default values
+{{{
+alias_database = hash:/macports/etc/postfix/aliases
+alias_maps = hash:/macports/etc/postfix/aliases
+}}}
+and not change anything at all in main.cf
 
-TODO
+aliases.db is created on the basis of the flat file aliases. Actually, we'll only need to edit one single line in aliases in order to get things working: 
+
+{{{
+# Person who should get root's mail. Don't receive mail as root!
+#root:		you
+}}}
+
+Un-comment the line starting with '''#root''' and change '''you''' to one of the following two options
+ 1. an ordinary email address: "person at domain.tld"
+ 1. the short name of a local user
+Then, just issue this command : {{{newaliases}}} and aliases.db will be created for you.
 
 === Step 3: '''starting the daemon''' ===
 

-------8<------8<------8<------8<------8<------8<------8<------8<--------

* The IP shown here might not mean anything if the user or the server is
behind a proxy.

--
MacPorts <http://www.macports.org/>
Ports system for Mac OS

This is an automated message. Someone at http://www.macports.org/ added your email
address to be notified of changes on howto/SetupPostfix. If it was not you, please
report to .


More information about the macports-changes mailing list