Logo
My Journal
Blog

Timeline

Blog

How to Send email direct from linux terminal

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 [email protected] you need to type following command:

$ mail [email protected]
Output:

[php]Subject: Hello
Hi,
Kamusta kana? sana ok ka/// 🙂
Ingats
xMoDx
. <Type DOT (.) followed by ENTER KEY>
Cc: <Press ENTER KEY>
[/php]
You need to type . (dot) to send an email.

To send contains of file (such as /var/log/messages) as mail body then use following command:
[php]$ mail -s ‘Subject here’ [email protected] < /var/log/messages[/php]

Please note that above command will NOT route an email if you do not have properly configured MTA/mail server. and check your spam folder for paid services like gmail for the mail might end up there

Leave A Comment