I have been studying linux for a long time and have written something for everyone to share. To receive SMTP emails from the network, we must run the Sendmail daemon on Linux. The following are specific commands and implementations.
For convenience, we should use the ntsysv command to add the Sendmail daemon to the Bootstrap program. In most cases, Linux will automatically include the Sendmail configuration in the Bootstrap program during installation. In this way, Linux starts the Sendmail daemon and listens to port 25 to process incoming emails.
The Sendmail configuration file is the/etc/sendmail. cf file, which contains most of the Sendmail configuration information, including the information required to select a route between the user Mail Program and the mail Transmission program. The Sendmail. cf file has three main functions:
· Define the Sendmail environment.
· Rewrite the address according to the syntax of the receiving email program.
· Map the address to the instructions required for sending emails.
Several commands are required to execute all these functions. Some macro definitions and optional commands can define the environment, some rewrite rules can rewrite the email address, and some mail programs can define the commands necessary for sending mail.
The sendmail. cf file is large and complex, but few changes are required. This article is mainly used in local info. Find "Cw" in the file. The original cf file, Cw should be:
Cwlocalhost
Add the names of all hosts on which the email address may be used after localhost. For example, a machine in the local network Virtual Brewery is vlager.vbrew.com and also called gopher.vbrew.com. The administrator of the network wants the two names of the machine to receive emails, then he needs to modify sendmail in this way. cf file:
Cwlocalhost vlager.vbrew.com gopher.vbrew.com
The above is just a simple method. If the system runs DNS, we can use DNS to resolve the host alias as follows) without adding the host alias gopher.vbrew.com. If DNS is not running, you must write all the machine names.
If the host used as the mail server has multiple hostnames), for example:
Vlager in a 191.72.1.1
Gopher in cname vlager
So we do not need to mark it on Cw. The system will find its alias through DNS.
If A machine has multiple names but each alias is created using A record, for example:
Vlager in a 191.72.1.1
Gopher in a 191.72.1.1
In this case, remember to write the name of the host to be received after Cw. If you forget to remember, emails sent from outside with an alias cannot be received normally, and the machine will complain:
"Local configuration error", for example, if. the Cw line in cf is Cw vlager.vbrew.com, so users in the LAN Virtual Brewery will not be able to use the e-mail address username@gopher.vbrew.com but only the username@vlager.vbrew.com, otherwise the above error will occur.
If a machine has multiple interfaces, each interface has its own name and needs to receive emails. In this case, all hostnames to receive should be written after Cw. In our example, the F command is processed as a comment. If you remove "sendmail" in front of it, it will be processed from/etc/sendmail. read the host alias in cw and store the alias in class w. Annotate the F command and let sendmail define the alias internally. This is the most common method.
When you open the/etc/mail/access file, you will see that some system access files are no longer under/etc/mail. If you cannot find them, use whereis to find them or check whether the installation is normal ):
- iption le)
- l-doc
- localhost.localdomain RELAY
- localhost RELAY
If the IP address of our host is 191.72.1.1, add its record in the last line. In this way, the last three lines of the modified file should be:
- localhost.localdomain RELAY
- localhost RELAY
- 191.72.1.1 RELAY
In addition, we can use sendmail to send and receive mail. But if we want someone else to use sendmail, and his IP address is 202.1625.22, then add the record item of his host to the last line, at this time, the last four lines of the file should be:
- localhost.localdomain RELAY
- localhost RELAY
- 191.72.1.1 RELAY
- 202.168.25.22 RELAY
When considering multiple users, sendmail allows us to add the entire class B or Class C address. The format is as follows:
- localhost.localdomain RELAY
- localhost RELAY
- 191.72 RELAY
- 202.168.25 RELAY
In this way, we add the entire network to sendmail. If you have an account in our system, you can use sendmail to send and receive emails. Linux also allows us to set the Post Office Protocol POP) Mail Server. The POP protocol is divided into two versions: POP2 and POP3. Obviously, POP3 is the new version of the Post Office Protocol, and now the Internet is mainly POP3. POP3 does not need to be configured. RedHat has already done this for us. You only need to modify the/etc/inetd. conf file to ensure that POP3 works properly:
After configuring sendmail, run the following command to check the directory read and write permissions to check for potential security vulnerabilities.
At this time, sendmail will start initializing alias data. If it is displayed on the screen:
- WARNING: writable directory /etc
- WARNING: writable directory /usr/spool/mqueue
This directory lists inappropriate write privileges. You should use the chmod and chown commands to avoid various security attacks. In general, we need to run the chmod and chown commands on the following directory: mqueue
Sendmail has some parameters that can be used to verify the address processing result to ensure the rationality of its new configuration. Once we think that the configuration can work properly, we can select friends on various sites and send emails to them. The-v parameter can be used to display the details of mail Transmission and the entire process of SMTP exchange between two sites. The following is a test example. The file test. cf is used. Once the test is successful, we can copy the file to/etc and change it to sendmail. cf.
- To: lack@vlager.vbrew.com
- From:janet
- Subject:Test for sendmail
- Lack,please reply if you see this,Thanks.
- ^D
- lark@ vlager.vbrew.com…..Connecting to vlager.vbrew.com via t
- cp…
- Trying 191.72.1.1 ….connected.
- 220 VLAGER.VBREW.COM on Web, 30 Sep 99 16:23:23 CST
- >>> HELLO maths.groucho.edu
- 250 VLAGER.VBREW.COM is my domain name
- >>> MAIL From:< gauss.maths.groucho.edu.>
- 250 OK
- >>> DATE
- 354 Enter mail body, End by new line with just a ‘.’
- >>>.
- 250 Mail Delivered
- >>> QUIT
- 221 VLAGER.VBREW.COM closing connection
- lack@vlager.vbrew.com …sent
We enter all the content before the CTRL-D, while sendmail displays the content after ^ D. By testing sendmail, we can discover potential configuration problems and solve these problems using some additional error checking tools provided by sendmail.
Article Reprinted from network management: http://www.bitscn.com/ OS /linux/200604/6356.html