{"id":1274,"date":"2011-11-08T19:34:51","date_gmt":"2011-11-08T13:34:51","guid":{"rendered":"http:\/\/techsatwork.com\/blog\/?p=1274"},"modified":"2016-01-07T11:31:05","modified_gmt":"2016-01-07T05:31:05","slug":"sending-an-email-in-unix-with-attachments","status":"publish","type":"post","link":"https:\/\/techsatwork.com\/?p=1274","title":{"rendered":"Sending an email in unix with attachments"},"content":{"rendered":"<p>Mailx is an easy way to send email from your unix\/linux system. \u00c2\u00a0With mailx you can get your server to send regular email or attach a file using your smtp server. \u00c2\u00a0Ensure your sendmail is configured to let mailx send emails. \u00c2\u00a0A good application for using mailx would be to send alerts, or process a file and then email it to somebody, extract data from your database or etl system and email the resulting data or file, etc.<\/p>\n<p>Here is how to send an email :<\/p>\n<p><em><span style=\"color: #ff9900;\">mailx -s &#8220;Subject goes here&#8221; &#8220;toemail@address&#8221; &#8220;body goes here&#8221;<\/span><\/em><\/p>\n<p><em><span style=\"color: #ff9900;\">mailx -r &#8220;sender@emailaddress&#8221; -s\u00c2\u00a0&#8220;Subject&#8221; &#8220;toemail@address&#8221; &#8220;body goes here&#8221;<\/span><\/em><\/p>\n<p>If the body is on a file :<\/p>\n<p><em><span style=\"color: #ff9900;\">mailx -s &#8220;Subject goes here&#8221; &#8220;toemail@address&#8221; &lt; body.txt<\/span><\/em><\/p>\n<p>If you want to send an attachment in the file :<\/p>\n<p><em><span style=\"color: #ff9900;\">uuencode data.csv data.csv|mailx &#8211;s &#8220;Subject goes here&#8221; &#8220;toemail@address&#8221;<\/span><\/em><\/p>\n<p>If you want to send an email with body and attachment :<\/p>\n<p><em><span style=\"color: #ff9900;\">uuencode data.csv data.csv &gt; datafile.csv \u00c2\u00a0<\/span><\/em><br \/>\n<em><span style=\"color: #ff9900;\"> cat body.txt datafile.csv &gt; combined.file<\/span><\/em><br \/>\n<em><span style=\"color: #ff9900;\"> mailx -s &#8220;Subject goes here&#8221; &#8220;toemail@address&#8221; &lt; combined.file<\/span><\/em><\/p>\n<p>The above three lines of code will enable you to send an email with body and an attachment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mailx is an easy way to send email from your unix\/linux system. \u00c2\u00a0With mailx you can get your server to send regular email or attach a file using your smtp server. \u00c2\u00a0Ensure your sendmail is configured to let mailx send emails. \u00c2\u00a0A good application for using mailx would be to send alerts, or process a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","site-transparent-header":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[303,358,142,1,275],"tags":[734,736,725,727,726,735,733,729,732,730,731,737,738,728],"class_list":["post-1274","post","type-post","status-publish","format-standard","hentry","category-database","category-how-to","category-linux","category-misc","category-unix","tag-attaching-file-on-emails-in-unix","tag-how-to-send-emails-with-attachment-in-unix","tag-mailx","tag-mailx-r","tag-mailx-s","tag-mailx-with-attachment","tag-sending-email-with-attachment","tag-sending-emails-on-unix","tag-sending-emails-with-attachment-on-unix","tag-sending-emails-with-body-and-attachment","tag-sendmail","tag-unix-email-with-attachment","tag-unix-email-with-body-and-attachment","tag-uuencode"],"_links":{"self":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts\/1274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1274"}],"version-history":[{"count":1,"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts\/1274\/revisions"}],"predecessor-version":[{"id":1275,"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts\/1274\/revisions\/1275"}],"wp:attachment":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}