How can I send an email through the UNIX mailx command? How can I send an email through the UNIX mailx command? unix unix

How can I send an email through the UNIX mailx command?


an example

$ echo "something" | mailx -s "subject" recipient@somewhere.com

to send attachment

$ uuencode file file | mailx -s "subject" recipient@somewhere.com

and to send attachment AND write the message body

$ (echo "something\n" ; uuencode file file) | mailx -s "subject" recipient@somewhere.com


Here you are :

echo "Body" | mailx -r "FROM_EMAIL" -s "SUBJECT" "To_EMAIL"

PS. Body and subject should be kept within double quotes.Remove quotes from FROM_EMAIL and To_EMAIL while substituting email addresses.


mailx -s "subjec_of_mail" abc@domail.com < file_name

through mailx utility we can send a file from unix to mail server. here in above code we can seefirst parameter is -s "subject of mail"the second parameter is mail ID and the last parameter is name of file which we want to attach