LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   procmail formail anonymous re-mailer for my very expensive two-way pager? (https://www.linuxquestions.org/questions/linux-software-2/procmail-formail-anonymous-re-mailer-for-my-very-expensive-two-way-pager-69285/)

jgilels 07-01-2003 09:47 AM

procmail formail anonymous re-mailer for my very expensive two-way pager?
 
"(my personal e-mail address)" = jerry@somedomain.com

I'd like to send an e-mail from my RIM950 two-way pager to my personal e-mail address (it's on a RH-9 Linux server), and have a shell/procmail/formail script change the headers to:

1. "From (my personal e-mail address)";

2. "To: " whatever's in the first line of the body of the message, formatted like "To:someone@somewhere.com" (without the quotes); and

3. Finally, send the body of the message - minus the first line and a following blank line (so I don't have to disclose my pager e-mail address and end up getting spammed on the device that costs me by the character).

It's sort of a simple, anonymous re-mailer for my very expensive two-way pager.

Any suggestions? I really don't quite understand formail.

david_ross 07-01-2003 01:10 PM

I don't know about formail. I would just write a perl script and have the mail piped to it. The program then sends the mail to the actual recipient.

jgilels 07-01-2003 02:41 PM

How do you do that, Davis? I don't know how to write perl.

Quote:

Originally posted by david_ross
I don't know about formail. I would just write a perl script and have the mail piped to it. The program then sends the mail to the actual recipient.

david_ross 07-01-2003 03:06 PM

I have adapted this from a script I already had but haven't tested it:
Code:

#!/usr/bin/perl

while(<STDIN>){$message .= $_}
@lines = split(/\n/,$message);

foreach $line (@lines){
if($content eq "started" && $line =~ /to:/i){
($to) = $line =~ /to: ?(.*)/i;
$content = "read"}
elsif($content eq "read"){$data .= $line."\n"}
elsif($line eq ""){$content="started"}
elsif($line =~ /^subject:/i){($subject) = $line =~ /subject: ?(.*)/i}
}

open(MAIL,"|/usr/lib/sendmail");
print MAIL "to: $to\n";
print MAIL "from: someone\@somewhere.com\n";
print MAIL "subject: $subject\n\n";
print MAIL "$data";
close(MAIL);


exit;

How you pipe the incomming messages to the script depends on what mail server you have.

jgilels 07-01-2003 05:47 PM

Well, David, it doesn't quite work. I can see how it might,. But, not understanding perl is a problem.

What are these words for?

"started"

"read"

Am I suppoed to put them in the message body or something?

Jerry.


Quote:

Originally posted by david_ross
I have adapted this from a script I already had but haven't tested it:
Code:

#!/usr/bin/perl

while(<STDIN>){$message .= $_}
@lines = split(/\n/,$message);

foreach $line (@lines){
if($content eq "started" && $line =~ /to:/i){
($to) = $line =~ /to: ?(.*)/i;
$content = "read"}
elsif($content eq "read"){$data .= $line."\n"}
elsif($line eq ""){$content="started"}
elsif($line =~ /^subject:/i){($subject) = $line =~ /subject: ?(.*)/i}
}

open(MAIL,"|/usr/lib/sendmail");
print MAIL "to: $to\n";
print MAIL "from: someone\@somewhere.com\n";
print MAIL "subject: $subject\n\n";
print MAIL "$data";
close(MAIL);


exit;

How you pipe the incomming messages to the script depends on what mail server you have.


jgilels 07-01-2003 06:02 PM

Also, I use sendmail (RedHat 9.0). I pick up the incoming mail using procmail and pipe it to your program.


Quote:

Originally posted by jgilels
Well, David, it doesn't quite work. I can see how it might,. But, not understanding perl is a problem.

What are these words for?

"started"

"read"

Am I suppoed to put them in the message body or something?

Jerry.


david_ross 07-02-2003 12:16 PM

No you shouldn't need those lines. Can you post an example message you sould send (including headers) then I will take alook for you (will probably be tomorrow)

jgilels 07-02-2003 12:31 PM

Please excuse the paging company jerks. They, naturally, have spelled my last name incorrectly.

The following is an actual message sent to eanon@secure800.com. I grabbed it from the /var/spool/mail/eanon file and pasted in here for you to look at.

=================================

From jgilils@imcingular.com Wed Jul 2 12:26:55 2003
Return-Path: <jgilils@imcingular.com>
Received: from mailrelay3.bellsouthips.com (mailrelay3.bellsouthips.com [198.138.100.112] (may be forged))
by localhost.localdomain (8.12.8/8.12.8) with ESMTP id h62HQth5008456
for <eanon@secure800.com>; Wed, 2 Jul 2003 12:26:55 -0500
Received: from gleam.imcingular.com (gleam [198.138.100.75])
by mailrelay3.bellsouthips.com (8.11.7+Sun/8.9.1) with ESMTP id h62HRSF16363
for <eanon@secure800.com>; Wed, 2 Jul 2003 13:27:28 -0400 (EDT)
Received: (root@localhost) by gleam.imcingular.com (8.8.8/SCA-6.6)
id NAA19233; Wed, 2 Jul 2003 13:27:53 -0400 (EDT)
From: <jgilils@imcingular.com> (JERRY GILELS)
To: eanon@secure800.com
Subject: I have a headache from too much formail
Urgent: Y
Message-Id: <15332076.1686275841@imcingular.com>
Date: Wed, 02 Jul 2003 13:27:53 -0400

To:davidross@somewhere.com

Dear Dr. Ross:

This is a sample of a message sent from my pager to eanon@secure800.com.

I'd like the From address to read jjgilels@earthlink.net and the To: address to be yours.

Jerry Gilels
214-526-9692

=================================

david_ross 07-03-2003 12:24 PM

Try changing the line:
open(MAIL, "|/usr/lib/sendmail");
to
open(MAIL, "|/usr/lib/sendmail -t");

jgilels 07-03-2003 05:51 PM

Well, David... It works from the command line when I cat this message into it:

================================

From jgilils@imcingular.com Thu Jul 3 17:40:17 2003
Return-Path: <jgilils@imcingular.com>
Received: from mailrelay1.bellsouthips.com (mailrelay1.bellsouthips.com
[198.138.100.110] (may be forged))
by localhost.localdomain (8.12.8/8.12.8) with ESMTP id h63MeGh5013563
for <eanon@secure800.com>; Thu, 3 Jul 2003 17:40:16 -0500
Received: from gleam.imcingular.com (gleam [198.138.100.75])
by mailrelay1.bellsouthips.com (8.11.7+Sun/8.9.1) with ESMTP id
h63MfIW09120
for <eanon@secure800.com>; Thu, 3 Jul 2003 18:41:18 -0400 (EDT)
Received: (root@localhost) by gleam.imcingular.com (8.8.8/SCA-6.6)
id SAA19146; Thu, 3 Jul 2003 18:41:22 -0400 (EDT)
From: <jgilils@imcingular.com> (JERRY GILELS)
To: eanon@secure800.com
Subject: Hahahahah
Urgent: Y
Message-Id: <15332076.1556898930@imcingular.com>
Date: Thu, 03 Jul 2003 18:41:22 -0400

To:jjgilels@earthlink.net

Hahahahahaha.

Ahahahahahahaha.

================================

But, when I either create an alias of

eanon: /home/eanon/eanon.pl

or implement a .procmailrc of

LOGFILE=procmail.log
VERBOSE=yes
SENDMAIL=/usr/sbin/sendmail

:0 :
* !^FROM_DAEMON
* $!^X-Loop: eanon@(secure800.com|telequery.net)
* $ ^From jgil.ls@imcingular.com

| eanon.pl

it doesn't work and gives me a line 3 syntax error message in the procmail.log:

procmail: [13565] Thu Jul 3 17:40:17 2003
procmail: Assigning "SENDMAIL=/usr/sbin/sendmail"
procmail: Match on ! "(^(Mailing-List:|Precedence:.*(junk|bulk|list)|To: Multiple recipients of |(((Resent-)?(F
rom|Sender)|X-Envelope-From):|>?From )([^>]*[^(.%@a-z0-9])?(Post(ma?(st(e?r)?|n)|office)|(send)?Mail(er)?|daemo
n|m(mdf|ajordomo)|n?uucp|LIST(SERV|proc)|NETSERV|o(wner|ps)|r(e(quest|sponse)|oot)|b(ounce|bs\.smtp) |echo|mirro
r|s(erv(ices?|er)|mtp(error)?|ystem)|A(dmin(istrator)?|MMGR|utoanswer))(([^).!:a-z0-9][-_a-z0-9]*)?[%@> ][^<)]
*(\(.*\).*)?)?$([^>]|$)))"
procmail: Match on ! "^X-Loop: eanon@(secure800.com|telequery.net)"
procmail: Match on "^From jgil.ls@imcingular.com"
procmail: Couldn't determine implicit lockfile from "eanon.pl"
procmail: Locking ".lock"
procmail: Executing "eanon.pl"
eanon.pl: line 3: syntax error near unexpected token `)'
eanon.pl: line 3: `while(<STDIN> ){$message .= $_}'
procmail: Error while writing to "eanon.pl"
procmail: Non-zero exitcode (2) from "eanon.pl"
procmail: Assigning "LASTFOLDER=eanon.pl"
procmail: Unlocking ".lock"
procmail: Locking "/var/spool/mail/eanon.lock"
procmail: Assigning "LASTFOLDER=/var/spool/mail/eanon"
procmail: Opening "/var/spool/mail/eanon"
procmail: Acquiring kernel-lock
procmail: Unlocking "/var/spool/mail/eanon.lock"
procmail: Notified comsat: "eanon@10848:/var/spool/mail/eanon"
From jgilils@imcingular.com Thu Jul 3 17:40:17 2003
Subject: Hahahahah
Folder: /var/spool/mail/eanon 900

Got any idea what I've done wrong? Permissions or something? We MUST be close now.

Jerry.

Quote:

Originally posted by david_ross
Try changing the line:
open(MAIL, "|/usr/lib/sendmail");
to
open(MAIL, "|/usr/lib/sendmail -t");


david_ross 07-04-2003 02:52 AM

Try making your .procmailrc file read:
Code:

:0
| "/home/eanon/eanon.pl"

This is much simpler and will hopefully solve the problem. I'm not familiar with .procmailrc files but I think that may be where the problem lies.

jgilels 07-04-2003 09:44 AM

Thank you so very much for your help. I actually found the answer myself. Yes, it was in the procmailrc. All I had to do was dot-slash eanon.pl:

| ./eanon.pl

Again, that you very much. How's the heather?

Jerry.

Quote:

Originally posted by david_ross
Try making your .procmailrc file read:
Code:

:0
| "/home/eanon/eanon.pl"

This is much simpler and will hopefully solve the problem. I'm not familiar with .procmailrc files but I think that may be where the problem lies.



All times are GMT -5. The time now is 09:14 PM.