Monday, July 5, 2010

Unix mail commands

Extracted from: http://www.cyberciti.biz/faq/linux-send-email-from-console/

To send an email from console you need to use mail command, which is an intelligent mail processing system which has a command syntax reminiscent of ed with lines replaced by messages. To send an email to somewhere@domain.com you need to type following command:

$ mail somewhere@domain.comOutput:

Subject: Hello
Hai,

How are you? Hope so you are fine :)

Take care

Babai

Vivek
.
Cc:

You need to type . (dot) to send an email. To send contains of file (such as /tmp/message) as mail body then use following command:
$ mail -s 'Hai' somewhere@domain.com < /tmp/messagePlease note that above command will NOT route an email if you do not have properly configured MTA/mail server.


*** Read mail ***
>>mail -f /var/spool/mail/ e.g., mail -f /var/spool/mail/root //root email
>>mbox //list all mails


Reference: http://www.computerhope.com/unix/umail.htm

No comments:

Post a Comment