I am trying to send the send email using the mail command as
mail -s "subject" email_address < email_text
but how will I confirm whether email is actually sent or not ( i.e. email_address is wrong or right)
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
For check if all the mails are gone the directory /var/spool/mqueue should be empty. This directory contains temporary files associated with the messages in the mail queue and may contain the log file. As example :
# ls -ltr /var/spool/mqueue -rw-r----- 1 root smmsp 240 Nov 13 22:11 dftADBBuZl027798 -rw-r----- 1 root smmsp 1149 Nov 13 23:18 dftADCIacE001585 -rw-r----- 1 root smmsp 12216 Nov 14 17:06 dftAE666SH027158 -rw-r----- 1 root smmsp 1530 Nov 14 21:10 qftADCIacE001585 -rw-r----- 1 root smmsp 1452 Nov 14 21:10 qftADBBuZl027798 -rw-r----- 1 root smmsp 930 Nov 14 21:33 qftABDxS6e024439
The df file contains the body of the email that has been queued. The qf file contains all the message headers, plus some other information, such as the (most recent) failure message and the number of attempts made to send this particular email. So you could find your email is not gone.
The df files remain static (until deleted) while the qf files are updated every time this queue is run.
mailq command will show you a summary of every mail still in the queue. Every daemon that adheres to the standards will implement this command, so it should work.
Look in (almost always, but might vary slightly per distro)
/var/log/mail.log for lines matching the destination address, then follow what happened to that particular message, and what response it received from the remote server when trying to deliver it.