📄 1408.html
字号:
#mailbox_transport = cyrus<br>
#mailbox_transport = lmtp:unix:/var/imap/socket/lmtp<br>
Step 2: Parameters specific to your environment<br>
<br>
Now it's time to grab some good old paper and a pencil. You will need these infos that are specific to your domain and network later. But then you should be able to focus on incorporating these.<br>
Question 1: What is the primary domain (or machine) that Postfix will be authoritative for?<br>
<br>
The mydomain parameter specifies the local internet domain name.. If you don't run a DNS server or don't have access to one provide a domain name. We will use example.com throughout this HOWTO as this domain is reserved for use in documentation.<br>
<br>
When we set this value we will add it to the parameter mydomain in main.cf.<br>
Question 2: What is the hostname of the machine that Postfix runs on?<br>
<br>
The myhostname parameter specifies the internet hostname of this mail system. Postfix needs to know its fully qualified domainname (FQDN). It will append this to all local users unless specified different by us.<br>
<br>
When we set this value we will add it to the parameter myhostname in main.cf.<br>
Question 3: What is the IP-Range of the Net that your (remote) machine stands in?<br>
<br>
We need this to tell Postfix that the IP that your Mailclient (for testing purposes) comes from is allowed to use Postfix as a relay.<br>
<br>
When we set this parameter, we'll set mynetworks in main.cf.<br>
Question 4: What is the IP-adress of the server that Postfix will run on?<br>
<br>
Important<br>
These are the parameters that will be used in the HOWTO. You will have to provide your own.<br>
Q1: example.com<br>
Q2: mail.example.com<br>
Q3: 172.16.0.0/24<br>
Q4: 172.16.0.2<br>
Step 3: Enable your Parameters<br>
<br>
Now that you have put your parameters down, we'll edit main.cf and put them into place.<br>
<br>
[root@example.com]# vi /etc/postfix/main.cf<br>
mydomain<br>
<br>
Search for mydomain = and you'll find #mydomain = domain.name<br>
<br>
We uncomment the line and set the value we defined in Q1. The mydomain parameter of this HOWTO now reads as follows:<br>
<br>
[HOWTO SETTING] mydomain = example.com<br>
myhostname<br>
<br>
Search for myhostname = and you'll find #myhostname = host.domain.name<br>
<br>
We uncomment the line and set the value we defined in Q2. The myhostname parameter of this HOWTO now reads as follows:<br>
<br>
[HOWTO SETTING] myhostname = mail.example.com<br>
mynetworks<br>
<br>
Search for mynetworks = and you'll find #mynetworks = 168.100.189.0/28, 127.0.0.0/8 and two more entries for mynetworks. We'll be using the style of the first one.<br>
<br>
We uncomment the line and add the value we defined in Q2 and remove 168.100.189.0/28. The mynetworks parameter of this HOWTO now reads as follows:<br>
<br>
[HOWTO SETTING] mynetworks = 172.16.0.0/24, 127.0.0.0/8<br>
Step 4: Enable common parameters<br>
<br>
Remember that we disabled a few lines that came with the RPM? We will now set these in their context. It's not that Postfix needs the parameters in a certain order. It just makes it easier for us humans to find them where they belong ;-)<br>
<br>
Note:<br>
Tuomo fixed that in his recent SRPMS. Still you will have to enable these.<br>
alias_maps<br>
<br>
Search for alias_maps = and you'll find #alias_maps = dbm:/etc/aliases and three more lines that offer different values.<br>
<br>
We uncomment the second line and set the value to hash:/etc/postfix/aliases. Our alias_maps parameter now reads as follows:<br>
<br>
alias_maps = hash:/etc/postfix/aliases<br>
alias_database<br>
<br>
Search for alias_database = and you'll find #alias_database = dbm:/etc/aliases and three more lines that offer different values.<br>
<br>
We uncomment the third line and set the value to hash:/etc/postfix/aliases. Our alias_database parameter now reads as follows:<br>
<br>
alias_database = hash:/etc/postfix/aliases<br>
<br>
That's it for a start. We're still away from having a sophisticated smtp server that saves us a lot of work and is a real pain to spammers, but we're very close to fire up Postfix and send our first message.<br>
Step 5: Enable verbose logging<br>
<br>
Postfix doesn't want to bother us with information into detailed depth unless we ask it to. Since we are still setting Postfix up and testing functions we might run into problems while doing that. So we'll have Postfix being more detailed about what's going on when it gets its work done. This will save us lot of time when we look for errors!<br>
<br>
In order to enable verbose logging we have to append a string that is passed to the smtpd when it is started. This is done in /etc/postfix/master.cf.<br>
<br>
[root@example.com]# vi /etc/postfix/master.cf<br>
<br>
search for smtpd and append -v.<br>
<br>
When your done it should look like this:<br>
<br>
# ==========================================================================<br>
# service type private unpriv chroot wakeup maxproc command + args<br>
# (yes) (yes) (yes) (never) (50)<br>
# ==========================================================================<br>
smtp inet n - n - - smtpd -v<br>
<br>
That's it for our first basic setup. Postfix should now be configured to accept messages from the local machine and from any machine who's IP matches the IP Range you specified when you answered Q3.<br>
Step 6: Add user for testmails<br>
<br>
We'll be sending quite some mail in this HOWTO. But to whom? We need a valid user on the local machine!<br>
<br>
[root@example.com]# adduser test<br>
[root@example.com]# passwd test<br>
<br>
This HOWTO sends mail to the user test. It's password is testpass.<br>
<br>
Feel free to add your own user, but remind that you'll have to replace our values with yours throughout this HOWTO.<br>
Step 7: Start Postfix<br>
<br>
Now it's time to start Postfix for the first time:<br>
<br>
[root@example.com]# /etc/init.d/postfix start<br>
<br>
You can tell it's up from the feedback the init-script provides; but will the Postfix-Server die after a few seconds because something is wrong?<br>
<br>
Let's check the process list and pipe it's output to grep which will grab for the string postfix in the output.<br>
<br>
[root@example.com]# ps axf | grep postfix<br>
7547 ? S 0:00 /usr/libexec/postfix/master<br>
<br>
Still there. OK, time to send our first mail. If it's gone check /var/log/maillog for error messages.<br>
Step 8: Send Testmail from local machine<br>
<br>
First we will verify that we are able to send mail on localhost to user test. This is the simpliest testcase that we have. If we succeed we will move on sending mails to test from a Mailclient that does not run on our Postfix server.<br>
<br>
[root@example.com]# mail test<br>
Subject: Test from localhost<br>
Test #1<br>
.<br>
Cc:<br>
[root@example.com]#<br>
<br>
Note:<br>
In case you are not familiar with the programm mail.<br>
Enter the name of the account that you want to mail to after you've entered mail<br>
Then your're prompted to enter the Subject.<br>
After this you may add the Body of your mail.<br>
You end your mail and send it away after entering a single dot '.' on a blank line and hitting enter.<br>
Step 9: Check for delivery of Testmail on local machine<br>
<br>
Did Postfix deliver our mail? We'll check by simply letting less open the file in /var/spool/mail for the user test.<br>
<br>
[root@example.com]# less /var/spool/mail/test<br>
From root@mail.example.com Fri Mar 15 21:09:54 2002<br>
Return-Path: <root@mail.example.com><br>
Delivered-To: test@mail.example.com<br>
Received: by mail.example.com (Postfix, from userid 0)<br>
id 029E640789; Fri, 15 Mar 2002 21:09:53 +0100 (CET)<br>
To: test@mail.example.com<br>
Subject: Test from localhost<br>
Message-Id: <20020315200953.029E640789@mail.example.com><br>
Date: Fri, 15 Mar 2002 21:09:53 +0100 (CET)<br>
From: root@mail.example.com (root)<br>
<br>
Test #1<br>
<br>
So it got delivered. Good. Let's go on to send some mail from another host.<br>
Step 10: Sending testmail from a remote host to a local user<br>
<br>
The simpliest Mailclient we can think of is a telnet client that connects to the smtp port 25. We'll be doing it the hard way, because we want to exclude sideeffects that might be introduced by other, more comfortable Mailclients.<br>
<br>
Look at the paper where you answered a few questions. It's time for Q4. We use 172.16.0.2 for our Postfix server. You'll have to replace this IP with yours in the following statement.<br>
<br>
First we will see if we can deliver mail to a local user. On your remote machine we telnet 172.16.0.2 25.<br>
<br>
Postfix comes up and greets us with it's smtpd banner:<br>
<br>
220 mail.example.com ESMTP Postfix<br>
<br>
We say hello and introduce ourselves:<br>
<br>
EHLO domain.com<br>
<br>
Postfix offers it's services:<br>
<br>
250-mail.example.com<br>
250-PIPELINING<br>
250-SIZE 10240000<br>
250-VRFY<br>
250-ETRN<br>
250-XVERP<br>
250 8BITMIME<br>
<br>
We tell where this testmail is comming from:<br>
<br>
mail from:<howto@domain.com><br>
<br>
Postfix responds:<br>
<br>
250 Ok<br>
<br>
We tell Postfix where this mail is going to:<br>
<br>
rcpt to:<test@example.com><br>
<br>
Postfix responds:<br>
<br>
250 Ok<br>
<br>
We tell Postfix that we'll be sending data<br>
<br>
data<br>
<br>
Postfix responds:<br>
<br>
354 End data with <CR><LF>.<CR><LF><br>
<br>
We write our message<br>
<br>
Test from remote host<br>
Test #2<br>
.<br>
<br>
Postfix responds:<br>
<br>
250 Ok: queued as 9BB3F40789<br>
<br>
Good. The mail got delivered. Time to end this session.<br>
<br>
quit<br>
<br>
Postfix responds:<br>
<br>
221 Bye<br>
<br>
So, we have just send our first mail from a remote host to a local user on the Postfix-server. But what if we wanted Postfix not do deliver to a local user, but to relay the message for us to another user on a remote host?<br>
Step 11: Delivering Mail to a remote user (Relaying)<br>
<br>
Again we telnet 172.16.0.2 25. We'll do as before with the only difference that this time we send to a remote (aka non-local) user. Since you've seen the principle in Step 10 we'll just summarize this session (S: = server, C: = client):<br>
<br>
S: 220 mail.example.com ESMTP Postfix<br>
C: EHLO example.com<br>
S: 250-mail.example.com<br>
S: 250-PIPELINING<br>
S: 250-SIZE 10240000<br>
S: 250-VRFY<br>
S: 250-ETRN<br>
S: 250-XVERP<br>
S: 250 8BITMIME<br>
C: mail from:<user@domain.com><br>
S: 250 Ok<br>
C: rcpt to:<howto@domain.com><br>
S: 250 Ok<br>
C: data<br>
S: 354 End data with <CR><LF>.<CR><LF><br>
C: Testmail relaying mail from user@domain.com to howto@domain.com<br>
C: Test #3<br>
C: .<br>
S: 250 Ok: queued as 84BA64078A<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -