ubuntu install sendmail

  1. Installation
    The sendmail function in ubuntu can send mails very conveniently, and ubuntu sendmail needs to install two packages first. Two packages that must be installed:

sudo apt-get install sendmail  
sudo apt-get install sendmail-cf

The following packages are optional:
squirrelmail //Provide webmail spamassassin //Provide mail filtering mailman //Provide mailing list support dovecot //Provide IMAP and POP receiving mail server daemon
squirrelmail //Provide webmail spamassassin //Provide mail filtering mailman //Provide mailing list support dovecot //Provide IMAP and POP receiving mail server daemon Note:
To use the most commonly used mail function under Ubuntu, you need to install mailutils,

Installation command: sudo apt-get install mailutils

To use the function with accessories, you also need to install sharutils,

Installation command: sudo apt-get install sharutils; (yum install sharutils)

Terminal input command: ps aux |grep sendmail

The output is as follows:
root     20978  0.0  0.3   8300  1940 ?        Ss   06:34   0:00 sendmail: MTA: accepting connections          
root     21711  0.0  0.1   3008   776 pts/0    S+   06:51   0:00 grep sendmail
Explain that sendmail has been successfully installed and started

Two, configuration
By default, sendmail will only send mail for local users. Only by extending it to the entire Internet can it become a real mail server.

Open the sendmail configuration macro file: /etc/mail/sendmail.mc
vi  /etc/mail/sendmail.mc
Find the following line:
DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl Modify Addr=0.0.0.0 to indicate that it can connect to any server.
Generate a new configuration file:

cd /etc/mail

mv sendmail.cf sendmail.cf~ //make a backup

m4 sendmail.mc> sendmail.cf //Make a backup #m4 sendmail.mc> sendmail.cf //> There are spaces on the left and right sides, indicating an error that sendmail-cf is not installed
Three, test sending mail
Common ways to send mail are as follows:

  1. How to write general mail: mail [email protected] Cc Edit the CC object, Subject: the subject of the mail, enter the carriage return, after the mail body, press Ctrl-D to end
  2. Quick sending method: echo "mail body" | mail -s mail subject [email protected]
  3. Send the content of the file as the body of the email: mail -s test [email protected] <test.txt
  4. Send mail with attachments: uuencode attachment name attachment display name | mail -s mail subject sending address
    For example: uuencode test.txt test.txt | mail -s Test [email protected]

In addition, it should be noted that the domain name used by sendmail is modified accordingly. The system defaults to localhost.localdomain. In fact, it does not need to be changed. However, some pop3 servers will filter out the emails from localhost.localdomain, which will cause the emails to not be checked normally. Fortunately, change the hostname to ensure the success rate of email sending.
The following is the modified configuration of my online machine for reference.

cat /etc/hosts

127.0.0.1       met.com    localhost.localdomain    localhost

The content of /etc/hosts generally has the following similar content:
  127.0.0.1     localhost.localdomain     localhost
Each line consists of three parts, each part is separated by a space.
The format is
IP address host name/domain name host name alias
That is, the first part: network IP address; the second part: host name or domain name; the third part: host name alias;
Then we need to modify it to our own domain name. Taking server110.com as an example, we will modify it to the following format:

127.0.0.1  server110.com    localhost
# cat /etc/mail/access
Connect:localhost.localdomain           RELAY
Connect:localhost                       RELAY
Connect:127.0.0.1
Connect:met.com                 RELAY
# cat /etc/mail/local-host-names 
met.com

After the modification is completed, restart the sendmail service and use the telnet command to test to see if it has taken effect

# telnet 127.0.0.125
Trying 127.0.0.1...
Connected to met.com(127.0.0.1).
Escape character is '^]'.220 met.com ESMTP Sendmail 8.13.8/8.13.8; Sun,10 Oct 201014:00:33+0800

From the above results, we can find that localhost.localdomain has become the domain name of met.com, indicating that the modification is successful

PS:

If an error is reported when using the sudo command: sudo: unable to resolve host webank.pw

It is because the two files /etc/hostname and /etc/hosts do not contain webank.pw

PS:

Author server successfully configured example:

youhong@webank$ cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
127.0.0.1 webank.pw

# The following lines are desirable for IPv6 capable hosts
::1  ip6-localhost TENCENT.site TENCENT ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

youhong@webank$ cat /etc/hostname
webank.pw

At this point, you can use the mailbox with domain name to send mail to other mailboxes.

**About sendmail logs and configuration files: **

After sendmail is successfully installed by default, its log is under /var/log, which records various logs of sendmail, and its configuration files are mainly distributed under the /etc/mail path.

Recommended Posts

ubuntu install sendmail
ubuntu18.04 install python2
ubuntu18.04 install docker
ubuntu12.04 install python3
Ubuntu install guide
ubuntu install nodejs
ubuntu 16 install asp.net
ubuntu install Jenkins
ubuntu install elasticsearch
ubuntu16.0.1 install pagoda
ubuntu18.04 install python
ubuntu 18.04 install teamviewer
Install apache+PHP under Ubuntu
install vscode on ubuntu18
Install node.js under Ubuntu
Install mysql-pytho in Ubuntu
ubuntu install zsh terminal
Install Redis on Ubuntu
Install R4 on ubuntu20
Install nvtop on Ubuntu 18.04
Install postgresql-10 on Ubuntu 18.04
Install python3.6 under Ubuntu 16.04
Install docker on Ubuntu
Ubuntu18.04 install opencv 3.2.0 solution
Install mysql under Ubuntu 16.04
Install Thrift under ubuntu 14.10
Install OpenJDK10 under Ubuntu
Install Caffe under Ubuntu 14.04
Install Docker on ubuntu18.04
Install nodejs10 on Ubuntu16
ubuntu install harbor warehouse
Install mysql on Ubuntu 14.04
Ubuntu16.04 install Mongodb tutorial
Install Django on ubuntu
Install Pytorch+CUDA on Ubuntu 16.04
2018-09-11 Install arduino under Ubuntu
Install Python3 on Ubuntu 14.04
Ubuntu18.04 install Asterisk16.10 + FreePBX15.0
Ubuntu19 install MySQL pit
ubuntu16.04 install node.js, npm
Install rJava on Ubuntu18
Install JDK10+ on Ubuntu
pcduino ubuntu install os
Install python in Ubuntu
Install JDK in Ubuntu19.10
Install Python3 on Ubuntu 16.04
Install ROS under ROS Ubuntu 18.04[2]
Install MySQL under Ubuntu
Install KDE on Ubuntu16.04.2
ubuntu install nginx server
Install Yarm-PM2 under Ubuntu
Install Docker on Ubuntu18
Install Python3.7 on Ubuntu
Install flashplayer on Ubuntu
ubuntu: install camera driver
ubuntu14.04 install jdk1.8 tutorial
Docker practice (1): install Docker on Ubuntu 16.04
Install VMware Tools in Ubuntu 18.04
ubuntu16.04 install caffe cpu version
Install OpenSSL 1.0.2 on Ubuntu Server 14.04
Install QQ robot on Ubuntu 16.04