snipt

Ctrl+h for KB shortcuts

Bash

Set up mail forwarding on linux

# add a .forward file to your home directory
touch .forward

# add your email address
vi .forward
<user>@<mail>.com

# change permission else it won't work
chmod 600 .forward

# test mail send, replace 'user' with your login
mailx -s 'test from cluster' user < /dev/null
https://snipt.net/embed/a588a48c6b7637586aa0094217ca27e2/
/raw/a588a48c6b7637586aa0094217ca27e2/
a588a48c6b7637586aa0094217ca27e2
bash
Bash
12
2019-08-21T20:44:42
True
False
False
/api/public/snipt/10890/
set-up-mail-forwarding-on-linux
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1"> 1</a> <a href="#L-2"> 2</a> <a href="#L-3"> 3</a> <a href="#L-4"> 4</a> <a href="#L-5"> 5</a> <a href="#L-6"> 6</a> <a href="#L-7"> 7</a> <a href="#L-8"> 8</a> <a href="#L-9"> 9</a> <a href="#L-10">10</a> <a href="#L-11">11</a> <a href="#L-12">12</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1"># add a .forward file to your home directory</span> </span><span id="L-2"><a name="L-2"></a>touch .forward </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1"># add your email address</span> </span><span id="L-5"><a name="L-5"></a>vi .forward </span><span id="L-6"><a name="L-6"></a>&lt;user&gt;@&lt;mail&gt;.com </span><span id="L-7"><a name="L-7"></a> </span><span id="L-8"><a name="L-8"></a><span class="c1"># change permission else it won&#39;t work</span> </span><span id="L-9"><a name="L-9"></a>chmod <span class="m">600</span> .forward </span><span id="L-10"><a name="L-10"></a> </span><span id="L-11"><a name="L-11"></a><span class="c1"># test mail send, replace &#39;user&#39; with your login</span> </span><span id="L-12"><a name="L-12"></a>mailx -s <span class="s1">&#39;test from cluster&#39;</span> user &lt; /dev/null </span></pre></div> </td></tr></table>
forwarding, linux, mail, server, shell