SunQuest
           Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old November 24th, 2000, 06:12 PM
Pepe Pepe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 71 Pepe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Hi! I'm trying to set up mail program to redirect email to perl script. Thanks chris22 for directions, but I'm not sure how to do this:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by chris22:
The script I'm using is a modified version of mailback ( http://www.cynicism.com/~derek/mailback/ ).

What you want to do is set up an aliases in sendmail that redirects incoming messages to this perl script.

e.g.

admin: "|/mail/mailback.pl"

Of course, make sure you run newaliases after making this change. Also, make sure your mailback.pl script is executable...
[/quote]

I have telnet access to my site. What should I exactly do to set up alias.
Will it redirect all incoming email to perl script, or just email from specific POP3 account (preferably) ?
And how to "run new aliases after making this change"?

Do I have to put script in /mail directory, because Perl scripts on my server can only be executed in cgi-bin directory?

[This message has been edited by Pepe (edited November 25, 2000).]

Reply With Quote
  #2  
Old November 25th, 2000, 02:38 AM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I haven't checked what "mailback" really is. Anyway, you don't seem to run the server yourself, so you obviously don't have write permission to /etc/aliases or /etc/mail/aliases.
I don't know what kind of permission you have and what mail server and OS the server runs, if you have access to your mailbox, you can always write a script to pipe messages and process it.
If your server runs qmail, like mine, users would have more control, you can easily create your mailling list or alias.


BTW, by looking at your quoted message, his name is "chris22", not carlos22.




[This message has been edited by freebsd (edited November 25, 2000).]

Reply With Quote
  #3  
Old November 25th, 2000, 07:09 AM
Pepe Pepe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 71 Pepe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
"mailback" is simple perl script that processes received email.

OS is Linux Red Hat and mail program is qmail. I know how to create alias through qmail web interface, but it can only redirect mail to other email address, not script. Or It can???

Reply With Quote
  #4  
Old November 25th, 2000, 03:45 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
>> but it can only redirect mail to other email address, not script


No. Qmail is much more powerful and secure than sendmail, you can do alot more.


>>OS is Linux Red Hat and mail program is qmail


That seems odd.


Anyway, I assume you have access to your account, here is how to do it.


1) echo -n "| preline perl /path/to/script.pl" > /var/qmail/alias/.qmail-perl


2) Create your scripts.pl
example:


#!/usr/local/bin/perl


@lines = <STDIN>;
open (MAIL, "| /var/qmail/bin/qmail-inject");
print MAIL "From: pepe@mydomain.comn";
print MAIL "To: pepe@mydomain.comn";
print MAIL "Subject: Testnn";
print MAIL "@linesn";
close (MAIL);


3) note, perl@mydomain.com is the email you need to send to. The entire content of the message you are going to send to perl@mydomain.com including the message header will be stored in the @lines above.


4) Send an email to perl@mydomain.com, your script.pl can be customized to whatever you like.


5) Check out this FAQ -> http://cr.yp.to/qmail/faq/incominguser.html#elm-filter


You can always pipe your message to a program


6) There are a few option to preline:
preline [-dfr] command


the command I used above is "perl /path/to/script.pl"


I didn't used any option but here you go:
-d Do not insert the Delivered-To header field
-f Do not insert the From header field
-r Do not insert the Return-Path header field

[This message has been edited by freebsd (edited November 30, 2000).]

Reply With Quote
  #5  
Old November 26th, 2000, 06:01 AM
Pepe Pepe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 71 Pepe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Thanks for quick response!
This is "error" which I get after typing first line:

bash: /var/qmail/alias/.qmail-perl: Permission denied


I'll ask my sys admin to give me permission if possible


[This message has been edited by Pepe (edited November 26, 2000).]

Reply With Quote
  #6  
Old November 26th, 2000, 10:40 AM
Pepe Pepe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 71 Pepe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
I consulted my sys administrator and he said that it is not possible because email server is on different computer, and I don't have shell access to it.

Reply With Quote
  #7  
Old November 26th, 2000, 04:36 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
>>bash: /var/qmail/alias/.qmail-perl: Permission denied

You can actually place the .qmail-perl in your HOME directory and it will work the same. However, the email address becomes pepe-perl@mydomain.com
You don't need shell access to upload .qmail-perl to your HOME directory, don't you?

>>he said that it is not possible because email server is on different computer

It doesn't matter so long as your HOME directory is NFS mounted from the email server box to your web server box. A proper configured qmail server should read user's HOME directory, just like sendmail reading .forward file in user's HOME directory.

Don't contact your sysadmin, just try this yourself:
1) Create .qmail-perl in your HOME directory with "pepe" in it, be sure to set the file pointer to the 2nd line (i.e. press ENTER)

2) Send an email to pepe-perl@mydomain.com should forward to pepe@mydomain.com

If this works, then put the "preline" stuff in place of just "pepe" and let your script to process it.

Reply With Quote
  #8  
Old November 26th, 2000, 05:53 PM
Pepe Pepe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 71 Pepe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
It didn't work. I putted ".qmail-perl" in my home directory with "pepe" in it and emails sent to pepe-perl@upitnik.net are bounced.

What exactly should be my HOME directory? Directory structure looks like this:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
/home/sites/sitexxx/ -can't write to it
/home/sites/sitexxx/htdocs/
/home/sites/sitexxx/cgi-bin/
/home/sites/sitexxx/users/ -can't write to it
/home/sites/sitexxx/users/upitnik/
/home/sites/sitexxx/users/upitnik/Maildir
...
[/code]
I tried putting .qmail-perl in every directory

Reply With Quote
  #9  
Old November 26th, 2000, 07:40 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
/home/sites/sitexxx/users/upitnik/

Reply With Quote
  #10  
Old November 26th, 2000, 08:45 PM
Pepe Pepe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 71 Pepe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by freebsd:
/home/sites/sitexxx/users/upitnik/[/quote]

Yes, I have uploaded ".qmail-perl" there, but it doesn't work.

Reply With Quote
  #11  
Old November 27th, 2000, 04:24 AM
Pepe Pepe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 71 Pepe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
I'm thinking about moving this task to other server - Cobalt Linux which uses sendmail program.
Can I redirect email to script by sendmail?

Reply With Quote
  #12  
Old November 27th, 2000, 05:24 AM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
>>Yes, I have uploaded ".qmail-perl" there, but it doesn't work

Make sure pepe@upitnik.net really exist or you can't use pepe-perl@upitnik.net at all.
You said the mail bounced, so what was the error message?
Have you configured a "catch all" alias for your domain via the web panel?

Maybe your host really configured to restrict users to control alias only via their web panel.

>>Can I redirect email to script by sendmail?

I thought chris22 already replied about this.

Reply With Quote
  #13  
Old November 27th, 2000, 04:08 PM
Pepe Pepe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 71 Pepe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
I fixed email redirect problem. I had pepe@upitnik.net address but it was alias. Now it's POP3 account and it works. Emails sent to pepe-perl@upitnik.net are redirected to pepe@upitnik.net.

Then I tried "preline" stuff. This is what I typed in telnet:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
echo "| preline perl /home/sites/site337/cgi-bin/script.pl" > /home/sites/site337/users/upitnik/.qmail-perl
[/code]

But script doesn't get executed, and sent email just remains in pepe@upitnik.net inbox.

Reply With Quote
  #14  
Old November 27th, 2000, 05:59 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
echo "| preline perl /home/sites/site337/cgi-bin/script.pl" > /home/sites/site337/users/upitnik/.qmail-perl

This looks fine. The problem could be your server. "preline" might not be in their path so you should find out where "preline" is and put the full path there.

By default, preline should be in /var/qmail/bin/

>>Emails sent to pepe-perl@upitnik.net are redirected to pepe@upitnik.net

How did you add the alias "pepe-perl"? Via the web panel or the .qmail-perl file? If you done that via .qmail-perl, then it's a good news to you that qmail is reading user's HOME dir.

Reply With Quote
  #15  
Old November 27th, 2000, 06:42 PM
Pepe Pepe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 71 Pepe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
I added alias by .qmail-perl file.

Here is transcript of what I did and it didn't work
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
[upitnik@mighty bin]$ whereis preline
preline: /usr/bin/preline /usr/man/man1/preline.1
[upitnik@mighty bin]$

echo "| /usr/bin/preline perl /home/sites/site337/cgi-bin/script.pl" > /home/sites/site337/users/upitnik/.qmail-perl
[/code]
I found preline and in /var/qmail/bin/ and
tried specifying that path, but it didn't help.
After executing preline command ".qmail-perl" that I previously uploaded with word "pepe" in it changes to this line:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
| /var/qmail/bin/preline perl /home/sites/site337/cgi-bin/script.pl
[/code]
... if it means something.

(Should email stay in inbox after perl script reads it?)

[This message has been edited by Pepe (edited November 27, 2000).]

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Email redirect to script - Help needed


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |