The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

procmail for secondary email addresses

Discussion in 'E-mail Discussions' started by ewv, Dec 4, 2004.

  1. ewv

    ewv Registered

    Joined:
    Dec 2, 2004
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    There has been a lot of discussion here and elsewhere on the net of problems getting procmail to work with cpanel, but I haven't found anything that gives definitive answers. What is required to configure cpanel, exim, the shell, and user script files to get procmail to work with individual .procmailrc files for each email address under a main account, including the main email address? Which parts have to be done by the server's administrator and what can be done by the owner of the files under the main account?
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
  3. ewv

    ewv Registered

    Joined:
    Dec 2, 2004
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    details for option 1?

    Unfortunately my procmail scripts do a lot more than crude testing, including writing and reading files and piping to sed, tr, formail, sendmail, etc., and I wouldn't have time or the means to rewrite and debug all this in another filter scripting language anyway. I have just been told that my whole account is about to be moved to a new linux server with cpanel instead of ensim. I am not getting answers from them about whether they can still support procmail, I don't have access to a cpanel server yet to be able to experiment and I can't wait until after the move breaks my system. I have to quickly ascertain whether a port is practical and if so how, or go somewhere else for open standards hosting.

    This is similar to a local invocation of procmail via a .forward on any unix system not configured to read .procmailrc files; is that what you mean? What do you do under cpanel for secondary mail accounts? My understanding is that cpanel does not build the usual user home directories for these mail users. Can home directories be created manually as a place to put their own .procmailrc? Can the mail accounts be configured in /etc/valias or in exim to pipe automatically into the procmail binary and use the individual .procmailrc's? Can pipes in procmail to sendmail be replaced with a functional equivalent using exim?

    Procmail is so popular that I thought there would be a complete documentation somewhere on how to configure and use it under cpanel, but all I have found on the net is lots of questions on how to do it. The best I have found so far is the year-old thread at http://forums.cpanel.net/showthread.php?postid=38189#poststop, which is less than complete and concludes pessismisticly. Doesn't cpanel provide the instructions?
     
  4. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    You've got the wrong end of the stick. This is not a cPanel issue, it's the Exim MTA that has the restriction - it doesn't basically like procmail and uses its own filtering system. You can use procmail, but to do so you have to pipe it through as a Forwarder with the restrictions indicated on the exim site.

    All the documentation there is, is on the exim.org site. If that doesn't show what you need, then you're simply out of luck unless you convert over to the exim filter system.
     
  5. ewv

    ewv Registered

    Joined:
    Dec 2, 2004
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Doesn't the configuration involve both cpanel and exim (and only partly because cpanel "comes with" exim)? What does exim not "liking" procmail mean? -- What difference does it make once the mail is piped from exim to an LDA, whether or not exim has done it's own filtering? Does it not pipe correctly to alternate locations specified by filters?

    What exactly do you mean by a "Forwarder" in this context -- something internal to exim or more general? The exim web page http://www.exim.org/exim-html-4.40/doc/html/spec.html Section 29.5 describes piping to procmail as an LDA. Is that what you mean by the restrictions on pipes? But can't it also be done locally in /etc/valias or /home/$user/.forward?

    -- or move somewhere else for hosting, which is also time-consuming :-(

    I also see that there is a 2001 O'Reilly book on Exim with several references to procmail in the index. O'Reilly is generally excellent but not having encountered exim before I don't have this one. Has anyone else on the forum used it for procmail?

    Exim's web page Section 29.5 on direct piping to procmail does not say what happens if there is no .procmailrc file (default delivery to the inbox?) and it does not address the issue of cpanel-constructed secondary mail users (with no home directories?) and where to put the individual .procmailrc files, which I brought up before. Does anyone else know how to do this? Doesn't this make the problem also a cpanel issue?
     
  6. apostate

    apostate Registered

    Joined:
    May 12, 2005
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    This seems to work pretty well

    I've found the following filter works pretty well for using procmail with secondary (virtual) e-mail addresses. Just add it to a site's vfilter (/etc/vfilters/site.com). It looks for the presence of a .procmailrc file in the virtual e-mail address's home directory. If the .procmailrc exists, it kicks of procmail with enough information to find the .procmailrc and default delivery to the virtual account's inbox. If there isn't a .procmailrc, delivery is handled normally.

    Code:
    if
      "${if exists{${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}lsearch{/etc/passwd}{$value}}}}/mail/${
    domain}/${local_part}/.procmailrc}{true}{false}}" is "true"
    then
     pipe "/usr/bin/procmail ORGMAIL=${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}lsearch{/etc/passwd}{
    $value}}}}/mail/${domain}/${local_part}/inbox DEFAULT=${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}
    lsearch{/etc/passwd}{$value}}}}/mail/${domain}/${local_part}/inbox HOME=${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/user
    domains}{$value}}}lsearch{/etc/passwd}{$value}}}}/mail/${domain}/${local_part}"
    endif
    
    I'm sure the word-wrapping is going to mangle that a little bit, but both the pipe "..." and "${if...}" should be on a single line, with no spaces inside the ${} variable expansion chunks.

    The only tricky thing, I guess, is configuring things for the users to have access to their own .procmailrc files. I have an idea how to do that, but there isn't enough room in the margin...
     
  7. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
Loading...

Share This Page