{"id":2201,"date":"2017-12-08T04:37:08","date_gmt":"2017-12-08T04:37:08","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=2201"},"modified":"2022-04-24T04:28:06","modified_gmt":"2022-04-24T04:28:06","slug":"various-commands-to-send-an-email-in-linux","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/various-commands-to-send-an-email-in-linux\/","title":{"rendered":"Linux Tutorials: Commands to send an email in Linux"},"content":{"rendered":"<p><strong>rajeshkumar created the topic: Various Commands to send an email in Linux<\/strong><br \/>\nSending mail<br \/>\nTo send a message to one or more people, mailx can be invoked with arguments which are the names of people to whom the mail will be sent. The user is then expected to type in his message, followed by an \u2018control-D\u2019 at the beginning of a line.<\/p>\n<p><code>mails -s \"this is test\" -a SG_COMM.sql.gz rajeshk@adobe.com &lt; raj.txt<\/code><\/p>\n<p><code>mailx rajesh@xyz.com &lt; \/tmp\/db_reorg.log<br \/>\necho \"This is test Subject\" | mailx rajesh@xyz.com<br \/>\nmailx -s \"This is test Subject\" rajesh@xyz.com &lt; test.txt<br \/>\necho \"This is test Subject\" |  mailx -c love@xyz.com -s \"Join us watching Star Wars\" rajesh@xyz.com<\/code><\/p>\n<p><strong>Send an email in Linux with attachment<\/strong><br \/>\nAttach \/tmp\/list.tar.gz and and send it<\/p>\n<p><code>uuencode \/tmp\/list.tar.gz \/tmp\/list.tar.gz | mailx -s \"Subject\" rajesh@xyz.com<\/code><\/p>\n<p><code>Email photo.png along with a text message read from body.txt<\/code><br \/>\n<code>cat body.txt; uuencode photo.png photo.png) | mail -s \"Subject\" rajesh@xyz.com<\/code><\/p>\n<p>Attach \/tmp\/filelist.tar.gz and read the content of a text using \/tmp\/body.txt<br \/>\nmutt -s &#8220;Backup status&#8221; -a \/tmp\/filelist.tar.gz rajesh@xyz.com &lt; \/tmp\/body.txt<\/p>\n<p>Unix command to send an email attachment<br \/>\nor<br \/>\nmailx command to send an email with attachment<\/p>\n<p>Code:<br \/>\n<code>uuencode  file1 file2 | mail user@companyname.co.in  -s \"subject\"<\/code><\/p>\n<p>uuencode is a utility which is to be found with sharutils. make sure its installed. To check wheterh its installed or not.<\/p>\n<p>which uuencode or<br \/>\nlocate uuencode or<br \/>\nrpm -qa | grep sharutils<\/p>\n<p>If you do not found, then you might have to install it. You need to install sharutils by folliwing commands&#8230;.<\/p>\n<p>Install uuencode<br \/>\n======================================<br \/>\nyum install shareutils<br \/>\nor<br \/>\nwget ftp.scientificlinux.org\/linux\/scientific\/6.2\/x86_64\/os\/Packages\/sharutils-4.7-6.1.el6.x86_64.rpm<br \/>\nrpm -ivh sharutils-4.7-6.1.el6.x86_64.rpm<br \/>\nRegards,<br \/>\nRajesh Kumar<br \/>\nTwitt me @<a href=\"http:\/\/twitter.com\/RajeshKumarIn\" target=\"_blank\" rel=\"noopener\"> twitter.com\/RajeshKumarIn<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>rajeshkumar created the topic: Various Commands to send an email in Linux Sending mail To send a message to one or more people, mailx can be invoked with arguments which&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[454],"tags":[460],"class_list":["post-2201","post","type-post","status-publish","format-standard","hentry","category-shell-script","tag-linux"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/2201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=2201"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/2201\/revisions"}],"predecessor-version":[{"id":29696,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/2201\/revisions\/29696"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=2201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=2201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=2201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}