LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-01-2003, 09:47 AM   #1
jgilels
LQ Newbie
 
Registered: Jun 2003
Location: Texas
Posts: 10

Rep: Reputation: 0
Question 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.
 
Old 07-01-2003, 01:10 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
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.
 
Old 07-01-2003, 02:41 PM   #3
jgilels
LQ Newbie
 
Registered: Jun 2003
Location: Texas
Posts: 10

Original Poster
Rep: Reputation: 0
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.
 
Old 07-01-2003, 03:06 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
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.
 
Old 07-01-2003, 05:47 PM   #5
jgilels
LQ Newbie
 
Registered: Jun 2003
Location: Texas
Posts: 10

Original Poster
Rep: Reputation: 0
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.
 
Old 07-01-2003, 06:02 PM   #6
jgilels
LQ Newbie
 
Registered: Jun 2003
Location: Texas
Posts: 10

Original Poster
Rep: Reputation: 0
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.
 
Old 07-02-2003, 12:16 PM   #7
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
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)
 
Old 07-02-2003, 12:31 PM   #8
jgilels
LQ Newbie
 
Registered: Jun 2003
Location: Texas
Posts: 10

Original Poster
Rep: Reputation: 0
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

=================================
 
Old 07-03-2003, 12:24 PM   #9
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
Try changing the line:
open(MAIL, "|/usr/lib/sendmail");
to
open(MAIL, "|/usr/lib/sendmail -t");
 
Old 07-03-2003, 05:51 PM   #10
jgilels
LQ Newbie
 
Registered: Jun 2003
Location: Texas
Posts: 10

Original Poster
Rep: Reputation: 0
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");
 
Old 07-04-2003, 02:52 AM   #11
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
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.
 
Old 07-04-2003, 09:44 AM   #12
jgilels
LQ Newbie
 
Registered: Jun 2003
Location: Texas
Posts: 10

Original Poster
Rep: Reputation: 0
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
formail fails on virtual user [qmail,vpopmail,procmail,formail] jonavogt Linux - Networking 2 01-15-2009 09:29 AM
formail with procmail priyesh Programming 2 10-22-2003 11:01 PM
Procmail and formail aBl_tR3kr Linux - Software 1 03-26-2003 10:15 AM
procmail and formail aBl_tR3kr Linux - Networking 1 03-26-2003 10:02 AM
procmail and formail aBl_tR3kr Linux - Newbie 0 03-26-2003 09:41 AM


All times are GMT -5. The time now is 07:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration