Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    71
    Rep Power
    15
    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).]
  2. #2
  3. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    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).]
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    71
    Rep Power
    15
    "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???
  6. #4
  7. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    >> 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).]
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    71
    Rep Power
    15
    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).]
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    71
    Rep Power
    15
    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.
  12. #7
  13. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    >>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.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    71
    Rep Power
    15
    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
  16. #9
  17. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    /home/sites/sitexxx/users/upitnik/
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    71
    Rep Power
    15
    <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.
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    71
    Rep Power
    15
    I'm thinking about moving this task to other server - Cobalt Linux which uses sendmail program.
    Can I redirect email to script by sendmail?
  22. #12
  23. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    >>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.
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    71
    Rep Power
    15
    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.
  26. #14
  27. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    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.
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    71
    Rep Power
    15
    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).]
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo