Last night a couple of questions came up (both from Steve, I think). The first is for a filter that converts a month name to a month number from within an ls listing. Locale is probably the most correct approach, but BFI works great too: ls -l | perl -p -e '@m=qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/; for ($i=0; $i<@m; $i++){ s/\b$m[$i]\b/$i+1/e}' And, how to generate an email from the command line with custom from/reply-to headers, use sendmail -t and write down the headers yourself: /usr/lib/sendmail -t <<MAIL From: "Angry Taxpayer" <testing@taxpayer.com> To: "Sean" <sean@ertw.com> Reply-To: "Paul Martin" <paulm@canadianrulingparty.gc.ca> Subject: Tax cuts Dear Sir, I pay too much in tax Tx MAIL -- Sean A. Walberg <sean@ertw.com> http://www.ertw.com
I'm not certain how much the sendmail differs from postfix but when I tried the below suggested in postfix it did not alter the Return-Path in the message header. -t allows you to extract recipients from the message headers but the Return-Path remained set to whichever user invoked the command. In postfix you need the -f option as follows: sendmail -t -f testing@taxpayer.com <<MAIL From: "Angry Taxpayer" <testing@taxpayer.com> To: "Dave" <bob@taxisbad.com> Reply-To: "Paul Martin" <paulm@canadianrulingparty.gc.ca> Subject: Tax cuts Dear Sir, I pay too much in tax Tx MAIL Regards, John Lange On Wed, 2004-02-11 at 08:23, Sean A. Walberg wrote:
Last night a couple of questions came up (both from Steve, I think). The first is for a filter that converts a month name to a month number from within an ls listing. Locale is probably the most correct approach, but BFI works great too:
ls -l | perl -p -e '@m=qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/; for ($i=0; $i<@m; $i++){ s/\b$m[$i]\b/$i+1/e}'
And, how to generate an email from the command line with custom from/reply-to headers, use sendmail -t and write down the headers yourself:
/usr/lib/sendmail -t <<MAIL From: "Angry Taxpayer" <testing@taxpayer.com> To: "Sean" <sean@ertw.com> Reply-To: "Paul Martin" <paulm@canadianrulingparty.gc.ca> Subject: Tax cuts
Dear Sir,
I pay too much in tax
Tx
MAIL -- John Lange BigHostBox.com (204) 885 0872
According to John Lange:
I'm not certain how much the sendmail differs from postfix but when I tried the below suggested in postfix it did not alter the Return-Path in the message header. -t allows you to extract recipients from the message headers but the Return-Path remained set to whichever user invoked the command.
In postfix you need the -f option as follows:
sendmail -t -f testing@taxpayer.com <<MAIL From: "Angry Taxpayer" <testing@taxpayer.com> To: "Dave" <bob@taxisbad.com> Reply-To: "Paul Martin" <paulm@canadianrulingparty.gc.ca> Subject: Tax cuts
That does seem to be the case with sendmail... As the man page indicates... -fname Sets the name of the ``from'' person (i.e., the envelope sender of the mail). This address may also be used in the From: header if that header is missing during initial submission. The envelope sender address is used as the recipient for deliv- ery status notifications and may also appear in a Return-Path: header. -f should only be used by ``trusted'' users (normally root, daemon, and net- work) or if the person you are trying to become is the same as the person you are. Otherwise, an X- Authentication-Warning header will be added to the message. ... -t Read message for recipients. To:, Cc:, and Bcc: lines will be scanned for recipient addresses. The Bcc: line will be deleted before transmission. So, in short, if you want to change the envelope "from" address, you need to use "-f". If you want to pull the list of recipients from the message headers, rather than explicitly list them on the command line, use "-t". -- Gilbert E. Detillieux E-mail: <gedetil@cs.umanitoba.ca> Dept. of Computer Science Web: http://www.cs.umanitoba.ca/~gedetil/ University of Manitoba Phone: (204)474-8161 Winnipeg, MB, CANADA R3T 2N2 Fax: (204)474-7609
participants (3)
-
gedetil@cs.umanitoba.ca -
John Lange -
Sean A. Walberg