<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dan&#039;s linux blog &#187; email</title>
	<atom:link href="http://www.dark.ca/tag/email/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dark.ca</link>
	<description>direct from the mysterious land of the sysadmin</description>
	<lastBuildDate>Tue, 10 Aug 2010 10:16:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>setting the from address in GNU mail</title>
		<link>http://www.dark.ca/2009/07/03/setting-the-from-address-in-mail/</link>
		<comments>http://www.dark.ca/2009/07/03/setting-the-from-address-in-mail/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 11:51:58 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[common tools]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.dark.ca/?p=99</guid>
		<description><![CDATA[Today i&#8217;m going to address a question that comes up again and again on the various Linux help forums and mailing lists (in one form or another) : « How do i set the From address when using mail ? » Of course, « mail » in this case refers to that most basic of [...]]]></description>
			<content:encoded><![CDATA[<p>Today i&#8217;m going to address a question that comes up again and again on the various Linux help forums and mailing lists (in one form or another) :</p>
<p>« How do i set the From address when using mail ? »</p>
<p>Of course, « mail » in this case refers to that most basic of all Linux mail applications : GNU mail.  Commonly part of the default software on a Linux box, it&#8217;s not used very often in an interactive capacity, but it still gets a <em>lot</em> of play in the System Administration world as a way to quickly fire off automated emails from scripts.  For example :</p>
<pre>$ echo "This is the message" | mail -s "This is the subject" user@domain.tld</pre>
<p>This would result in a message that&#8217;s <em>from</em> whatever raw user@system that the local mailing software detects, such as « systemcheck@2.1.0.192.int.domain.tld » or some such thing.  Normally, whatever defaults (including the From address) that get used are good enough, but occasionally it can be handy to have a finer level of control ; for example, policy restrictions on your local mail relay, or just because the default From address looks bad and you want to make it more readable.</p>
<p>The solution, like so many others in the Linux world, is straightforward once you already know about it, but just obscure enough that it isn&#8217;t obvious at first.  The man page for « mail » on Ubuntu (and, likely, other distros as well) has this tasty little morsel of information listed as the <em>very first</em> option :</p>
<pre>-a, --append=HEADER: VALUE Append given header to the message being sent</pre>
<p>« Headers » form part of every email message, and are used to store all sorts of information about the email, from such pedestrian items as « From: » and « To: », to more esoteric things like Spam analysis breakdowns and binary encoding methods.  For now, the important thing to realise is that the From: address is contained within the From header, and using the argument noted above, we can set it quite easily :</p>
<pre>$ echo "The message" | mail -s "The subject" --append=FROM:sensible@domain.tld user@domain.tld</pre>
<p>This would send the same message as above, but with the From: address set to « sensible@domain.tld ».  In fact, <em>any</em> header can be altered in this fashion, not just the From header &#8211; so if you ever have the need to change other headers, now you know at least one way. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dark.ca/2009/07/03/setting-the-from-address-in-mail/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
