Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First you need to compose the message. The bare minimum is composed of these two headers:</p> <pre><code>MIME-Version: 1.0 Content-Type: text/html </code></pre> <p>... and the appropriate message body:</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;head&gt;&lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Hello, world!&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Once you have it, you can pass the appropriate information to the <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?mail" rel="noreferrer">mail</a> command:</p> <pre><code>body = '...' echo $body | mail \ -a "From: me@example.com" \ -a "MIME-Version: 1.0" \ -a "Content-Type: text/html" \ -s "This is the subject" \ you@example.com </code></pre> <p>This is an oversimplified example, since you also need to take care of charsets, encodings, maximum line length... But this is basically the idea.</p> <p>Alternatively, you can write your script in Perl or PHP rather than plain shell.</p> <h1>Update</h1> <p>A shell script is basically a text file with Unix line endings that starts with a line called <a href="http://en.wikipedia.org/wiki/Shebang_%28Unix%29" rel="noreferrer">shebang</a> that tells the shell what interpreter it must pass the file to, follow some commands in the language the interpreter understands and has execution permission (in Unix that's a file attribute). E.g., let's say you save the following as <code>hello-world</code>:</p> <pre><code>#!/bin/sh echo Hello, world! </code></pre> <p>Then you assign execution permission:</p> <pre><code>chmod +x hello-world </code></pre> <p>And you can finally run it:</p> <pre><code>./hello-world </code></pre> <p>Whatever, this is kind of unrelated to the original question. You should get familiar with basic shell scripting before doing advanced tasks with it. Here you are a couple of links about <strong>bash</strong>, a popular shell:</p> <p><a href="http://www.gnu.org/software/bash/manual/html_node/index.html" rel="noreferrer">http://www.gnu.org/software/bash/manual/html_node/index.html</a></p> <p><a href="http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html" rel="noreferrer">http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload