Sending email from Linux command line

Sending Simple mail

root@mypc [~]# mail -s “test message from centos”
hello from centos linux command line
root@mypc [~]#

Here is the received message



Send with an attachment

For this create a blank file first

root@odc [~/mail]# touch attachment

Now the sending part

root@odc [~/mail]# mail -a ./attachment < ./attachment
No message, no subject; hope that’s ok
root@odc [~/mail]#

Here what we did is , redirecting attachment content as the body of the mail, that is Null as we used touch for creating that file

Inbox view


  • sara

    You can also use sendmail:

    /usr/sbin/sendmail < /file/to/send