Sending email from Linux command line

Sending Simple mail

root@mypc [~]# mail -s “test message from centos” meabi@meabi.com
hello from centos linux command line
Ctrl+D
root@mypc [~]#

Here is the received message

image

 

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  abhilash@morbits.net < ./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

image

  • sara

    You can also use sendmail:

    /usr/sbin/sendmail user@domain.com < /file/to/send