When working with Linux servers, you need to get mails from them,
they like to alert you on different issues like “help – im dying from lack of space” etc.
you can easily setup mail forwarding in your sendmail through an external mail server.
all the sendmail config files are in /etc/mail.
edit the mailertable file and add a line like this:
for example – lets say you work for data.com and you want to send mails to the data.com domain from your Linux machine through the data.com mail server which is called mail.data.com, so your line in mailertable should be:
to check that your company mail server will actually allow you to forward mails through it, you need to connect to the smtp service and try to send a mail, this will work from the command line:
telnet mail.data.com 25
this will try to connect to the mail server smtp port and if there is no firewall problem then you should see something like 220 localhost.localdomain ESMTP Sendmail 8.13.8/8.13.8 as a reply.
at this point you try to send a mail through the server.
send mail from command line
telnet to the machine and copy paste this text after editing it:
mail from: test@email
rcpt to: test@email
whatever you want the mail to have in the body.
(the “.” in the end will finish the mail – dont forget it).
so lets explain:
helo domain_name – change the domain_name to your domain – data.com for example
mail from: the email you want the mail to look like it was sent from – firstname.lastname@example.org
rcpt to: who you want to get this test mail – email@example.com
so the new updated test text would look like:
mail from: firstname.lastname@example.org
rcpt to: email@example.com
Subject: test mail from command line
this is test number 1
sent from linux box
if there arent any permissions issues the mail server should show you something like: 250 2.0.0 n4CNnNPG003499 Message accepted for delivery
there is another nice command line tool to show you whats your Linux server current mail queue: mailq:
[root@centos mail]# mailq
/var/spool/mqueue (1 request)
—–Q-ID—– –Size– —–Q-Time—– ————Sender/Recipient———–
n4CNnNPG003499 0 Wed May 13 02:49 test@email
(host map: lookup (email): deferred)
Total requests: 1