{"id":4950,"date":"2016-08-16T11:35:58","date_gmt":"2016-08-16T11:35:58","guid":{"rendered":"https:\/\/cpanelplesk.com\/wp62\/?p=4950"},"modified":"2021-02-04T05:28:44","modified_gmt":"2021-02-04T05:28:44","slug":"send-mail-terminal-using-mail-command","status":"publish","type":"post","link":"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/","title":{"rendered":"How to send mail from terminal using mail command"},"content":{"rendered":"<p><span style=\"color: #000000;\">Today I\u2019ll help you get started with sending mails from the Linux command line and in shell scripts.We will begin with the \u201cmail\u201d command.<\/span><\/p>\n<h3><strong><span style=\"color: #000000;\">1) MAIL<\/span><\/strong><\/h3>\n<p><span style=\"color: #000000;\">First we run a quick test to make sure the \u201csendmail\u201d application is installed and working correctly on server. Execute the following command, Make sure to replace \u201cyou@youremailid.com\u201d with your e-mail address.<\/span><\/p>\n<div class=\"command-sh\">\n<pre class=\"lang:default decode:true \">mail \u201cHello world\u201d you@youremailid.com<\/pre>\n<\/div>\n<p><a href=\"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/mail-test-from-terminal\/\" rel=\"attachment wp-att-4952\"><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-4952 pleslwp\" src=\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2016\/08\/Mail-test-from-terminal.jpg\" alt=\"Mail test from terminal\" width=\"511\" height=\"144\" srcset=\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2016\/08\/Mail-test-from-terminal.jpg 511w, https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2016\/08\/Mail-test-from-terminal-300x85.jpg 300w, https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2016\/08\/Mail-test-from-terminal-320x90.jpg 320w, https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2016\/08\/Mail-test-from-terminal-239x67.jpg 239w\" sizes=\"(max-width: 511px) 100vw, 511px\" \/><\/a><\/p>\n<h3><span style=\"color: #000000;\">2<strong>) How to use mail command to send mail from terminal ?<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\">You can use the mail command with below format and send the mail from terminal. After typed your subject press Ctrl+D, The command prompt will ask you if you want to mark a copy of the mail to any other address, if needed type it or else, hit enter. Check your mailbox. This command will send out a mail to the email id mentioned with the subject, \u201cHello world\u201d.<\/span><\/p>\n<p><span style=\"color: #000000;\">Now, i\u2019m going to check my gmail inbox whether the mail are received or not. And found that its received.<\/span><\/p>\n<h3><strong><span style=\"color: #000000;\">3) How to use mail command to send mail from terminal with echo ?<\/span><\/strong><\/h3>\n<p><span style=\"color: #000000;\">Use the mail &amp; echo command with below format and send the mail from terminal.<\/span><\/p>\n<div class=\"command-sh\">\n<pre class=\"lang:default decode:true \"># echo \"This is test mail by seemab\" | mail -s Test humparidil@gmail.com<\/pre>\n<\/div>\n<h3><strong>4) Sending main from a shell script<\/strong><\/h3>\n<p><span style=\"color: #000000;\">Now you can send mails from your shell scripts. Here\u2019s a simple shell script that gives you a reading of the usage of space on your partitions and mails the data to you.<\/span><\/p>\n<div class=\"command-sh\">\n<pre class=\"lang:default decode:true\">#!\/bin\/bash\r\ndf -h &gt; \/tmp\/mail_report.log\r\nfree -m &gt;&gt; \/tmp\/mail_report.log\r\nmail -s \u201cdisk and RAM report\u201d humparidil@gmail.com &lt; \/tmp\/mail_report.log<\/pre>\n<\/div>\n<p><span style=\"color: #000000;\">Save these lines in a file on your Linux server and run it. You will receive a mail containing the results of the command. <\/span><\/p>\n<p><span style=\"color: #000000;\">That&#8217;s all.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I\u2019ll help you get started with sending mails from the Linux command line and in shell scripts.We will begin with the \u201cmail\u201d command. 1) MAIL First we run a quick test to make sure the \u201csendmail\u201d application is installed and working correctly on server. Execute the following command, Make sure to replace \u201cyou@youremailid.com\u201d with [&#8230;]<\/p>\n<p><a class=\"understrap-read-more-link\" href=\"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/\">Continue Reading&#8230;<\/a><\/p>\n","protected":false},"author":2,"featured_media":1960,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,14],"tags":[],"class_list":["post-4950","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cpanel","category-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to send mail from terminal using mail command - cPanel Plesk<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How to send mail from terminal using mail command - cPanel Plesk\" \/>\n<meta name=\"twitter:description\" content=\"Today I\u2019ll help you get started with sending mails from the Linux command line and in shell scripts.We will begin with the \u201cmail\u201d command. 1) MAIL First we run a quick test to make sure the \u201csendmail\u201d application is installed and working correctly on server. Execute the following command, Make sure to replace \u201cyou@youremailid.com\u201d with [...]Continue Reading...\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/03\/webmail.png\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Seemab Saleem\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/\"},\"author\":{\"name\":\"Seemab Saleem\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648\"},\"headline\":\"How to send mail from terminal using mail command\",\"datePublished\":\"2016-08-16T11:35:58+00:00\",\"dateModified\":\"2021-02-04T05:28:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/\"},\"wordCount\":265,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\"},\"image\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/03\/webmail.png\",\"articleSection\":[\"Cpanel\",\"Linux\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/\",\"name\":\"How to send mail from terminal using mail command - cPanel Plesk\",\"isPartOf\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/03\/webmail.png\",\"datePublished\":\"2016-08-16T11:35:58+00:00\",\"dateModified\":\"2021-02-04T05:28:44+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/#primaryimage\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/03\/webmail.png\",\"contentUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/03\/webmail.png\",\"width\":256,\"height\":256},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cpanelplesk.com\/wp62\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to send mail from terminal using mail command\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#website\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/\",\"name\":\"cPanel Plesk\",\"description\":\"Blog on famous hosting control panels\",\"publisher\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cpanelplesk.com\/wp62\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\",\"name\":\"Farooq Omer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png\",\"contentUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png\",\"width\":300,\"height\":44,\"caption\":\"Farooq Omer\"},\"logo\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648\",\"name\":\"Seemab Saleem\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g\",\"caption\":\"Seemab Saleem\"},\"description\":\"Linux Server Administrator, Web Hosting engineer. I'm dealing with Linux servers since 2014. I started this blog to share the work i love with the world . let me know if you need any assistance. Thanks!!\",\"sameAs\":[\"https:\/\/cpanelplesk.com\/wp62\"],\"url\":\"https:\/\/cpanelplesk.com\/wp62\/author\/cmb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to send mail from terminal using mail command - cPanel Plesk","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/","twitter_card":"summary_large_image","twitter_title":"How to send mail from terminal using mail command - cPanel Plesk","twitter_description":"Today I\u2019ll help you get started with sending mails from the Linux command line and in shell scripts.We will begin with the \u201cmail\u201d command. 1) MAIL First we run a quick test to make sure the \u201csendmail\u201d application is installed and working correctly on server. Execute the following command, Make sure to replace \u201cyou@youremailid.com\u201d with [...]Continue Reading...","twitter_image":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/03\/webmail.png","twitter_misc":{"Written by":"Seemab Saleem","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/#article","isPartOf":{"@id":"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/"},"author":{"name":"Seemab Saleem","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648"},"headline":"How to send mail from terminal using mail command","datePublished":"2016-08-16T11:35:58+00:00","dateModified":"2021-02-04T05:28:44+00:00","mainEntityOfPage":{"@id":"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/"},"wordCount":265,"commentCount":0,"publisher":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13"},"image":{"@id":"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/#primaryimage"},"thumbnailUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/03\/webmail.png","articleSection":["Cpanel","Linux"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/","url":"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/","name":"How to send mail from terminal using mail command - cPanel Plesk","isPartOf":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/#primaryimage"},"image":{"@id":"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/#primaryimage"},"thumbnailUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/03\/webmail.png","datePublished":"2016-08-16T11:35:58+00:00","dateModified":"2021-02-04T05:28:44+00:00","breadcrumb":{"@id":"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/#primaryimage","url":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/03\/webmail.png","contentUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/03\/webmail.png","width":256,"height":256},{"@type":"BreadcrumbList","@id":"https:\/\/cpanelplesk.com\/wp62\/send-mail-terminal-using-mail-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cpanelplesk.com\/wp62\/"},{"@type":"ListItem","position":2,"name":"How to send mail from terminal using mail command"}]},{"@type":"WebSite","@id":"https:\/\/cpanelplesk.com\/wp62\/#website","url":"https:\/\/cpanelplesk.com\/wp62\/","name":"cPanel Plesk","description":"Blog on famous hosting control panels","publisher":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cpanelplesk.com\/wp62\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13","name":"Farooq Omer","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/","url":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png","contentUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png","width":300,"height":44,"caption":"Farooq Omer"},"logo":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/"}},{"@type":"Person","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648","name":"Seemab Saleem","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g","caption":"Seemab Saleem"},"description":"Linux Server Administrator, Web Hosting engineer. I'm dealing with Linux servers since 2014. I started this blog to share the work i love with the world . let me know if you need any assistance. Thanks!!","sameAs":["https:\/\/cpanelplesk.com\/wp62"],"url":"https:\/\/cpanelplesk.com\/wp62\/author\/cmb\/"}]}},"_links":{"self":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts\/4950","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/comments?post=4950"}],"version-history":[{"count":0,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts\/4950\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/media\/1960"}],"wp:attachment":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/media?parent=4950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/categories?post=4950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/tags?post=4950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}