There is a very nice tutorial
on how to install and setup mail server on Ubuntu 18.04 LTS. It's a bit involved.
For our class, I just want to be able to setup an SMTP server (called "bind9")
on our standard 32-bit Ubuntu 16.04 system
so you can play with it a little bit.
(The problem with a real SMTP server these days is that they all want to go "secure" and it's a lot more difficult to talk to such a server.)
So, I start with the above tutorial and simplify it so you can try things out
without getting the full-blown SMTP to work on your 32-bit Ubuntu 16.04 system.
This SMTP server will only respond to messages coming from within the 32-bit Ubuntu 16.04 system (i.e., localhost).
Here's a quick summary about what you can do to get setup an SMTP server and send and receive email. If you need more details,
please see the original tutorial.
DISCLAIMER: I do not know what every command below is doing or the meaning of lines inside some configuration files. Some commands are specific to the way the bind9 SMTP server is set up.
Add the student account to be able to receive mail.
Install bind9 (BIND stands for "Berkeley Internet Name Domain").sudo usermod -aG mail student Edit /etc/hosts:sudo apt-get -y update sudo apt-get install -y bind9 Change the full name of your machine to be localhost.localdomain:sudo pico /etc/hostsChange the first line from:to the following 3 lines:127.0.0.1 localhostThen save the file and quit pico.127.0.0.1 localhost localhost.localdomain 127.0.0.1 ns1.localhost.localdomain 127.0.0.1 mail.localhost.localdomain Create and edit /var/cache/bind/db.test:sudo hostnamectl set-hostname localhost.localdomain Run the following command to make sure that the above file is entered correctly:sudo pico /var/cache/bind/db.testEnter the following lines:Then save the file and quit pico.$ORIGIN localhost.localdomain. $TTL 1D @ IN SOA ns1 root( 1 ;serial 1D ;refresh 2H ;retry 2W ;expire 5H ;minimum ); @ IN NS ns1 ns1 IN A 127.0.0.1 mail IN A 127.0.0.1 @ IN MX 5 mail Edit /etc/bind/named.conf.default-zones:sudo named-checkzone localhost.localdomain /var/cache/bind/db.testYou should see the following printout:zone localhost.localdomain/IN: loaded serial 1 OK Edit /etc/bind/named.conf.options:sudo pico /etc/bind/named.conf.default-zonesAdd the following 4 lines at the end of the file:Then save the file and quit pico.zone "localhost.localdomain." { type master; file "db.test"; }; Start bind9:sudo pico /etc/bind/named.conf.optionsFind the following 3 lines:and change them to:// forwarders { // 0.0.0.0; // };Then save the file and quit pico.forwarders { 0.0.0.0; }; Install postfix so that you can send email:sudo service bind9 start Install mailutils so that you can read email:sudo apt install -y postfixYou will be prompted with a couple of questions. Just accept the default values ("Internet Site" and "localhost"). sudo apt install -y mailutils
Send email to student@localhost.localdomain:
This is a commandline program. When you are done with your message, press <Ctrl+D> to terminate and send email.mail student@localhost.localdomain
To check if you have an email, do:
If from doesn't print anything, it means that you have no email.from
To read your email, do:
This is a commandline program. You can type an message number (e.g., 1) to read the corresponding email number. Type "h" to list email numbers and header information. Type "d #" to delete a particular email number. Type "q" to quit.
Let's try the commands mentioned in section (2.3) of the textbook (on "Electronic Mail in the Internet").
Of course, you must not send such an e-mail to anyone outside of your virtual machine!
Run telnet to connect to the SMTP server on localhost: Now go back and check to see if you got an e-mail from Bill Gate.telnet localhost.localdomain 25You should see:Tell the SMTP server that you are saying hello from mars.planets:Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 localhost ESMTP Postfix (Ubuntu)Tell the SMTP server that you have a mail from bill.gates@microsoft.come:HELO mars.planetsTell the SMTP server that you have a mail fo student@localhost.localdomain:MAIL FROM: bill.gates@microsoft.comTell the SMTP server that you are ready to send mail data:RCPT TO: student@localhost.localdomainType the following:DATAIf you have no more messasges to send, disconnect by typing:From: Bill Gates <bill.gates@microsoft.com> To: Student <student@localhost.localdomain> Subject: Greetings from Bill Gates Seriously, this is Bill Gates. --Bill Gates .and telnet will terminate.QUIT
|