How to Send Mail Manually using Postfix Mail Service

Posted on

This is an article where the title is specifically defined as ‘How to Send Mail Manually using Postfix Mail Service’. The article itself is described as an attempt to send mail using a specific command for testing and trial as soon as the Postfix Mail Service has been installed. So, first of all the step for sending mail is by installing Postfix Mail Server.

After successfully installed Postfix Mail Server the next step is to make sure that the service is enabled and it is activated. Below is the command used to check the current running status of Mail Server :

[user@hostname ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2017-12-05 18:06:58; 3 weeks 1 days ago
 Main PID: 2459 (master)
   CGroup: /system.slice/postfix.service
           ├─ 2459 /usr/libexec/postfix/master -w
           ├─ 2461 qmgr -l -t unix -u
           ├─ 2472 tlsmgr -l -t unix -u
           ├─26316 pickup -l -t unix -u
           ├─26384 cleanup -z -t unix -u
           ├─26385 trivial-rewrite -n rewrite -t unix -u
           └─26386 smtp -t unix -u

Hint: Some lines were ellipsized, use -l to show in full.
[user@hostname ~]#

After confirming the service which is actually running, the process for testing and performing a trial for sending mail can be carried out and can be executed. Below is the pattern of command for sending mail using Postfix Mail Service :

[root@mailrelay ~]# echo "Test mail from postfix" | mail -s "Test Postfix" user@gmail.com
[root@mailrelay ~]#

Off course, the above command execution where it is actually sending an email to an email account named ‘user@gmail.com’ as an example in this context has actually succeeded. It can be checked in the status of the Postfix Mail Service as shown below :

[root@mailrelay ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: active (running) since Sel 2017-12-05 18:06:58 WIB; 3 weeks 1 days ago
 Main PID: 2459 (master)
   CGroup: /system.slice/postfix.service
           ├─ 2459 /usr/libexec/postfix/master -w
           ├─ 2461 qmgr -l -t unix -u
           ├─ 2472 tlsmgr -l -t unix -u
           ├─26316 pickup -l -t unix -u
           ├─26384 cleanup -z -t unix -u
           ├─26385 trivial-rewrite -n rewrite -t unix -u
           └─26386 smtp -t unix -u

....
Dec 28 10:54:56 mailrelay.server.web postfix/pickup[26316]: A3ACA8023F7: uid=0 from=
Dec 28 10:54:56 mailrelay.server.web postfix/cleanup[26384]: A3ACA8023F7: message-id=<20171228035456.A3ACA8023F7@mailrelay.server.web>
Dec 28 10:54:56 mailrelay.server.web postfix/qmgr[2461]: A3ACA8023F7: from=<root@mailrelay.server.web>, size=493, nrcpt=1 (queue active)
Dec 28 10:54:57 mailrelay.server.web postfix/smtp[26386]: A3ACA8023F7: to=<user@gmail.com>, relay=xxx.xxx.xxx.xxx[xxx.xxx.xxx.xxx]:25, delay=0.72, delays=0.03/0/0/0.69, dsn=2.6.0, status=sent (250 2.... for delivery)
Des 28 10:54:57 mailrelay.server.web postfix/qmgr[2461]: A3ACA8023F7: removed
Hint: Some lines were ellipsized, use -l to show in full.
[root@mailrelay ~]#

As shown in the above output generated, there is an information given based on the status checked through the execution of the command which is depicted in the line below :

Dec 28 10:54:56 mailrelay.server.web postfix/qmgr[2461]: A3ACA8023F7: from=<root@mailrelay.server.web>, size=493, nrcpt=1 (queue active)

The above output line is giving the information that there is an email send from an account named ‘root@mailrelay.server.web’ within the active queue

Dec 28 10:54:57 mailrelay.server.web postfix/smtp[26386]: A3ACA8023F7: to=<user@gmail.com>, relay=xxx.xxx.xxx.xxx[xxx.xxx.xxx.xxx]:25, delay=0.72, delays=0.03/0/0/0.69, dsn=2.6.0, status=sent (250 2.... for delivery)

The above output line is giving another information that an email has already  sent to an account named ‘user@gmail.com’.

One thought on “How to Send Mail Manually using Postfix Mail Service

Leave a Reply