{"id":13771,"date":"2022-01-10T10:15:05","date_gmt":"2022-01-10T10:15:05","guid":{"rendered":"https:\/\/linuxways.net\/?p=13771"},"modified":"2022-01-11T11:17:46","modified_gmt":"2022-01-11T11:17:46","slug":"mail-command-in-linux","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/mail-command-in-linux\/","title":{"rendered":"Mail Command in Linux"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>Mail is the easiest way to send messages to your friends, partners. There are many ways to allow users to send emails, and you may not know it, Linux can also help you send emails using the mail command on the terminal. You can write the subject, content with the email address and send it by mail command.<\/p>\n<p>This command is built-in on Linux distributions. Now we will start introducing you to using the mail command in Linux. Hope you understand.<\/p>\n<h2>Installing the mail package<\/h2>\n<p>Run the apt command to install the mailutils package:<\/p>\n<pre>$ sudo apt install mailutils<\/pre>\n<p>Output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"968\" height=\"108\" class=\"wp-image-13772\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-183.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-183.png 968w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-183-300x33.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-183-768x86.png 768w\" sizes=\"auto, (max-width: 968px) 100vw, 968px\" \/><\/p>\n<p>Then run:<\/p>\n<pre>$ sudo apt install postfix<\/pre>\n<p>Output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"968\" height=\"253\" class=\"wp-image-13773\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-184.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-184.png 968w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-184-300x78.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-184-768x201.png 768w\" sizes=\"auto, (max-width: 968px) 100vw, 968px\" \/><\/p>\n<h2>Using the mail command<\/h2>\n<p>The syntax of the mail command:<\/p>\n<pre>$ mail -s \"subject\" [recipient's email]<\/pre>\n<p>[Type the message]<\/p>\n<p>[Press Ctrl + D]<\/p>\n<p>CC [You can skip by pressing Enter]<\/p>\n<p>To understand clearly, we will try to send a mail to address &#8220;ubuntu@linuxer&#8221;:<\/p>\n<pre>$ mail -s \"test\" ubuntu@linuxer<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"968\" height=\"92\" class=\"wp-image-13774\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-185.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-185.png 968w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-185-300x29.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-185-768x73.png 768w\" sizes=\"auto, (max-width: 968px) 100vw, 968px\" \/><\/p>\n<p>Another way, you can send mail by a single command:<\/p>\n<pre>$ mail -s \"test\" ubuntu@linuxer &lt;&lt;&lt; 'Test'<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"968\" height=\"46\" class=\"wp-image-13775\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-186.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-186.png 968w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-186-300x14.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-186-768x36.png 768w\" sizes=\"auto, (max-width: 968px) 100vw, 968px\" \/><\/p>\n<p>If you want to attach the text file:<\/p>\n<pre>$ mail -s \"test\" ubuntu@linuxer &lt;&lt;&lt; 'Hello, I want to share a file for you' \/home\/ubuntu\/test\/test1.txt<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"968\" height=\"67\" class=\"wp-image-13776\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-187.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-187.png 968w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-187-300x21.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-187-768x53.png 768w\" sizes=\"auto, (max-width: 968px) 100vw, 968px\" \/><\/p>\n<p>You can check the mail by command:<\/p>\n<pre>$ mail<\/pre>\n<p>Output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"166\" class=\"wp-image-13777\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-188.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-188.png 969w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-188-300x51.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-188-768x132.png 768w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/><\/p>\n<p>To read the email, enter the email&#8217;s sequence number and press Enter. For example, I want to read the 3rd email:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"968\" height=\"307\" class=\"wp-image-13778\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-189.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-189.png 968w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-189-300x95.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-189-768x244.png 768w\" sizes=\"auto, (max-width: 968px) 100vw, 968px\" \/><\/p>\n<p>To delete the email:<\/p>\n<pre>&amp; d [email's sequence number]<\/pre>\n<p>For example:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"965\" height=\"147\" class=\"wp-image-13779\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-190.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-190.png 965w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-190-300x46.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-190-768x117.png 768w\" sizes=\"auto, (max-width: 965px) 100vw, 965px\" \/><\/p>\n<h2>Conclusion<\/h2>\n<p>We introduced you to how to use the mail command in Linux.<\/p>\n<p>Thank you for reading!<\/p>","protected":false},"excerpt":{"rendered":"<p>Introduction Mail is the easiest way to send messages to your friends, partners. There are many ways to allow users to send emails, and you may not know&hellip;<\/p>","protected":false},"author":1,"featured_media":13827,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,4,5,83,165,2],"tags":[35,834],"class_list":["post-13771","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-debian","category-mint","category-opensuse","category-red-hat","category-ubuntu","tag-linux","tag-mail-command"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/13771","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=13771"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/13771\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/13827"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=13771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=13771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=13771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}