1. First method.
We will use the “sendmail” command.
Create a file.
$ vi /tmp/email.txt
It should have this content.
Subject: E-mail testing
E-mail content on the first line.
E-mail content on the second line.
In order to send the e-mail, execute this command.
$ sendmail firstname.lastname@example.org < /tmp/email.txt
2. Second method.
By using the “mail” command.
$ mail -s E-mail Testing email@example.com < /dev/null
“-s E-mail testing” is the subject of the mail.
Sending the e-mail with a file that is attached.
$ mail -a /opt/db.sql -s Backup File firstname.lastname@example.org < /dev/null
-a /opt/db.sql (name of the file that is attached).
Sending the e-mail to multiple persons.
$ mail -s Test Email email@example.com,firstname.lastname@example.org < /dev/null
3. Third method.
By using the mutt command.
It is very similar to the mail command.
mutt -s Test Email email@example.com < /dev/null
Mutt with attach.
mutt -s Testing E-mail -a /opt/db.sql firstname.lastname@example.org < /dev/null
4. Forth method.
Using the telnet command.
$ telnet localhost smtp
Connected to localhost.localdomain (127.0.0.1).
Escape character is ^].
250 incvice.com Hello incvice.com [127.0.0.1]
mail from: email@example.com
250 2.1.0 firstname.lastname@example.org Sender ok
rcpt to: email@example.com
250 2.1.5 firstname.lastname@example.org Recipient ok
354 Enter mail, end with . on a line by itself
250 2.0.0 r9M95xgc014513 Message accepted for delivery
Connection closed by foreign host.