Creating an issue for Postfix support, which I intend to work on once the spaces/purl issue is resolved.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DarrellDuane’s picture

+1

Nigel Cunningham’s picture

Notes on my work so far (** Warning: I am not a Postfix guru and this is work in progress! **)

You could use a pipe command like Mailman uses, but I'm going to try a special transport because I think this might give greater flexibility (ie make it so it's possible to just make changes to the database to get new mailing lists working).

My initial version:

  1. Set up virtual alias. I want to be able to email test@crca.org.au, but crca.org.au is a virtual host. So start by renaming the destination to something we can use.
  • Add the following to /etc/postfix/virtual:
test@crca.org.au        test@lists.crca.org.au
  • Run postmap /etc/postfix/virtual to update the postfix database.
  • (Longer term aim: Get these entries using a MySQL query, like I already do for other virtual addresses)

  • Set up transport for the organic groups addresses:
    • Add the following to /etc/postfix/transport:
    test@lists.crca.org.au  organic_groups:
    
  • Run postmap /etc/postfix/transport to update the postfix database.
  • (Once I get one address going right, I'll remove the 'test' and perhaps use a different subdomain to lists. It must be in mydestination in main.cf, though. Must not be a virtual domain).

  • Set up the pipe command
    • Add the command to /etc/postfix/master.cf to define the transport:
    organic_groups  unix    -       n       n       -       -       pipe
      flags=FR user=crca-website argv=/home/crca-website/public_html/sites/all/modules/og_mailinglist/postfix_og_mailinglist/store.sh ${original_recipient}
    

    Unlike the exim support, I'm using one parameter (original_recipient) because I want the software to see the original address (test@crca.org.au), not the aliased one (test@lists.crca.org.au). I'm also currently using a simple shell script store.sh because I'm still debugging the delivery:

    #!/bin/bash
    cat >/tmp/message.$$
    cat /tmp/message.$$ | /home/crca-website/public_html/sites/all/modules/og_mailinglist/postfix_og_mailinglist/og_mailinglist_exim4_transport.php $1 >/tmp/message.$$.log 2>&1
    

    The contents of postfix_og_mailinglist/og_mailinglist_exim4_transport.php are basically the same as the exim directory - I'm just tweaking as I go.

    The adjustments I've made so far:

    1. Use explode to split the original recipient address, given above. I know this makes my original_recipient change above redundant at the moment, but I have in the back of my mind a desire to maybe use domain names in list/group names later.
    2. Explicit drush path. Don't assume postfix sets a path you can use!
    3. Not using the drush aliases. Wouldn't work for me. May look into this more once I have the basic functionality working
    #!/usr/bin/php
    <?php
    
    // Reads in raw email off the STDIN and posts the email using our drush command on the appropriate site.
    
    // Grab the raw email message from stdin.
    $fd = fopen("php://stdin", "r");
    while (!feof($fd)) {
      $raw_email .= fread($fd, 1024);
    }
    
    // Load site aliases
    require_once('site_aliases.php');
    $sites = og_mailinglist_site_aliases();
    
    // The commandline contains the original recipient email address.
    // Split this into the mailbox and domain.
    $parts = explode("@", $argv[1]);
    $mail_username = $parts[0];
    $mail_domain = $parts[1];
    
    print("Posting for " . $mail_username . "\n");
     
    foreach ($sites as $domain => $drush_alias) {
      if (strtolower($mail_domain) === $domain) {
        // This email is to one of our domains. Let's post it.
        // Multiline arguments are a bit tricky -- see http://www.qc4blog.com/?p=589
        exec("EMAIL=$(cat <<EOF\n" . escapeshellarg($raw_email) . "\nEOF\n);
             /usr/local/bin/drush -v -d -r /home/crca-website/public_html/ -l http://crca.org.au  ogm-post-email \"\$EMAIL\" " . $mail_username,
             $result);
        print_r($result);
      }
    }
    
  • Get postfix to reload it's configuration (not sure this is necessary)
  • postfix reload
    

    With the above, if I just get store.sh to save the email, the posting php script works for me if I run it from the command line. It's not yet, however, working if I make the store script invoke the transport php script (as I have above). Still debugging.

    I've noticed that og_mailinglist_transport.inc (in the top level module directory) needs modification if you're not using exim. It includes an explicit path to exim for sending email. Haven't yet looked to see what this email is it's trying to send because I also seem to have issues with the script parsing my thunderbird emails. Attachments are not getting handled properly and the email just mentioned is addressed to "@crca.org.au". Will use xdebug soon, but right now I need to get on with other things.

    kyle_mathews’s picture

    Great work so far!

    I'm a bit confused -- so with postfix you have to configure something in postfix for each additional group you add? With exim, every email is just sent to og_mailinglist_exim4_router.php which then decides if the email is addressed to a properly configured group. Is that not possible with postfix? It'd be quite tedious and error-prone to have to add configuration each time a group is created.

    On the "exim -t" command -- we should be able to replace that with "sendmail -t". When you install exim at least, it creates an alias from sendmail to exim. I'd assume postfix does the same.

    Nigel Cunningham’s picture

    Hi Kyle.

    Well, you can get Postfix to run a MySQL query to pull a list of users from a database (see the Mailfix module). That's what I'm already doing for Postfix integration I'm using. But as far as I know, it doesn't run scripts to check if email addresses are valid. It gives you the option of text files compiled into databases or database queries like MySQL.

    That's why I'm thinking of doing the MySQL query way longer term. First, though, I thought I'd get the basic functionality going.

    Yes, sedmail -t will work - that's what I've changed it to in my copy.

    Nigel Cunningham’s picture

    Status: Active » Needs review

    After some more debugging, I've got it going. The trick was to ensure that the command is invoked from the top level directory in the drupal installation, because there's a views module (and maybe more) that uses a relative path and therefore fails if you're in the wrong directory.

    So, my pipe command in /etc/postfix/master.cf is:

    organic_groups unix - n n - - pipe -v
    flags=FR user=crca-website directory=/home/crca-website/public_html argv=sites/all/modules/og_mailinglist/postfix_og_mailinglist/og_mailinglist_exim4_transport.php ${original_recipient}

    Kyle, do you want me to prepare a patch or will you take the above and merge it with whatever other work you're doing in this area?

    Nigel

    Nigel Cunningham’s picture

    (PS: I realise I still need to do the MySQL stuff, but I'm imagining that the above might form a basis for instructions for a simpler setup)

    kyle_mathews’s picture

    A patch would be great. If you could put all the postfix changes in a folder with an INSTALL.txt file, similar to what I've done with exim, that'd be great.

    On the mysql stuff, the Drupal groups would be the postfix "users"?

    Nigel Cunningham’s picture

    They'd be addresses, but not users. As with mailman aliases, there'd be no mailbox for the addresses - the email is piped directly to the command given on stdin.

    I'll seek to prepare a patch today.

    kyle_mathews’s picture

    In addition to the patch, if you could branch og_mailinglist on github and start pushing there, that'd make it easier for me to cherry-pick your changes and commit them.

    Thanks!

    Nigel Cunningham’s picture

    Will do.

    DarrellDuane’s picture

    What does the -v option to the pipe command in #5 do? Is it really needed? It seems to break my master.cf.

    aireworth’s picture

    Nigel, many thanks for this. (many thanks to Kyle as well).
    I think I'm following this now, but I'm writing this to help get clear in my brain the steps you're going through.
    I'm no postfix expert either, but it would appear that using /etc/postfix/virtual you could map mail to all your groups to a single real user - e.g in
    /etc/postfix/virtual:
    somegroup@mysite.co.uk OGM_user@mydestination
    another_group@mysite.co.uk OGM_user@mydestination
    afirstgroup@myothersite.co.uk OGM_user@mydestination

    As you've done, a transport map for that single user could then be used to call ..../postfix_og_mailinglistog_mailinglist_exim4_transport.php. Looks like there is no need to further check the domain its being sent to as valid, or if the group is a valid group, as only group(s)@domian(s) listed in the virtual table will ever be sent to OGM_user@mydestination. And if @mydestination is something.localhost.localdomain, mail from the outside should never arrive to this user directly either.
    I haven't tried it but it looks like this wouldn't work for multisite setup unless we can get the Drush site alias stuff working as per Kyle's original code.

    Thanks again - sorry for rambling
    Colin

    kyle_mathews’s picture

    I've removed the drush integration in favor of a much simpler method for POSTing emails. See #782360: Replace the current Drush system for handling incoming mail with a mimemail-inspired POSTing system, the function og_mailinglist_post() in og_mailinglist_transport.inc and the new installation instructions for exim. I think getting postfix working should be a lot simpler now. I'll be rolling a new alpha next week but for now, grab it from github.

    Nigel Cunningham’s picture

    Cool. Sorry I've been quiet for so long - busy with a focus on other things. I do still want to work on this, and hope to get back to it shortly.

    DarrellDuane’s picture

    I've got OGM working with Postfix. The php and installation instructions are available at http://github.com/DarrellDuane/og_mailinglist/tree/master/postfix_og_mai...

    Nigel, or somoene else, can you please give it a try and let me know if it all works well?

    Thanks,
    --Darrell

    kyle_mathews’s picture

    I've looked over the code as well (haven't tested it though) and it looks good. Nigel, if you can test it and give it your go ahead, I'll commit it asap and release another beta.

    Nigel Cunningham’s picture

    It looks fine to me, but it will be a few hours before I can test it.

    I was working on using MySQL queries to get the configuration info, thereby removing the need to edit additional files as groups are added/removed. I'd suggest that Darrell's instructions be committed. Perhaps we can add my method later as an alternative.

    Will seek to get back to you this afternoon.

    DarrellDuane’s picture

    Yes, I'd love to get it set up so that one could create an OGM list/group without having to edit any files. I'd think that if we knew that a domain was dedicated to use with OGM that there would be a way we could set all mail received by it to go to the og_mailinglist; postfix handler, but I haven't figured out how to do that. Short of that, and for cases when the domain is used for local deiivery or other things besides OGM lists, it'd be nice to enable those sites using a DB Configuration method for their postfix site to have the entries made into the postfix database by OGM, or to write out to the virtual and transport files and compile them the way that MailMan does.

    Thanks Nigel!

    Nigel Cunningham’s picture

    It works.

    I would add a note making people aware that the domain name you enter at admin/og/og_mailinglist needs to be example.com, not lists.example.com (in the case of the example given), while the domain given in site_info.php needs to be lists.example.com. Took a bit of debugging to figure that out :)

    tobias’s picture

    Hi Nigel -

    I have groups.kabissa.org in both places. Agree that the documentation could be improved on installation - feel free to suggest improvements to the install.txt or contribute to the documentation which currently lives here: http://kabissa.org/og-mailinglist-documentation

    Cheers,

    Tobias

    kyle_mathews’s picture

    Status: Needs review » Needs work

    Darrell, if you could make the changes that NigelCunningham suggested (as makes sense to you) and commit them to github, I'll get them committed to d.o. Thanks everyone!

    kyle_mathews’s picture

    A more advanced setup would be great as well but that can go in later.

    tobias’s picture

    It seems to me this setup could be streamlined, modelling the exim and qmail setup. I have not been able to test this yet myself but may get a chance if I help setup another OGM site that uses postfix.

    Principles:
    * set up a dedicated domain name for OGM (eg groups.yourserver.com)
    * specify groups.yourserver.com in both OGM admin and site_info.php
    * use the same transport script as exim, as I did for qmail (let's avoid more dependencies in case this script changes)
    * call the transcript script directly via /etc/postfix/transport as follows:
    @groups.yourserver.com organic_groups:

    The benefits of this approach are avoiding confusion with other mailboxes on the same domain, no longer needing to create transport rules for each list, and not using a "forked" transport script.

    Nigel, Colin and Darrell, can you try this and see if it works for you?

    Cheers,

    Tobias

    ps - I am not sure the code in /etc/postfix/transport will work - I am extrapolating from http://www.postfix.org/VIRTUAL_README.html#forwarding .. see line 10 below.

    Some providers host domains that have no (or only a few) local mailboxes. The main purpose of these domains is to forward mail elsewhere. The following example shows how to set up example.com as a mail forwarding domain:
    
     1 /etc/postfix/main.cf:
     2     virtual_alias_domains = example.com ...other hosted domains...
     3     virtual_alias_maps = hash:/etc/postfix/virtual
     4 
     5 /etc/postfix/virtual:
     6     postmaster@example.com postmaster
     7     joe@example.com        joe@somewhere
     8     jane@example.com       jane@somewhere-else
     9     # Uncomment entry below to implement a catch-all address
    10     # @example.com         jim@yet-another-site
    11     ...virtual aliases for more domains...
    
    Nigel Cunningham’s picture

    Yeah, that's the sort of thing mentioned in previous messages.

    It's not always an option, though. I, for example, already have some mailing lists in the crca.org.au domain that I'm working towards switching to og_mailinglist. I'm not going to ask hundreds of people to change multiple addresses.

    I certainly agree that instructions should be given that make it easy to set up, but I also think we need to cover the more difficult cases as well. I'm more than happy to cut code to cover the corner cases I'm running into already.

    tobias’s picture

    Thanks Nigel - I can appreciate your logic.

    Perhaps a solution for your use case would be to use your method just for the existing lists you have and then set up the rest of your system using a devoted domain name.

    I would modify it slightly though to use the exim transport script, which can get the domain name from the command line and the username from the email address in the message piped to it.

    Cheers,

    Tobias

    Nigel Cunningham’s picture

    One more issue: As described in http://www.postfix.org/pipe.8.html under SINGLE-RECIPIENT DELIVERY, we'll want

    [transport]_destination_recipient_limit = 1
    

    in order to get og_mailinglist invoked once per mailinglist (where a message is sent to multiple lists).

    Perhaps we could/should modify og_mailinglist to handle multiple lists at once?

    tobias’s picture

    +1 this looks like a good idea to me - probably needs to get its own issue if kyle agrees.

    I hope you are able to get OGM going on postfix without forking/creating a new script to run. I think it's great that qmail works with the same script that kyle uses on his exim system, and it would be great if you could do the same so we don't end up with multiple scripts.

    Cheers,

    Tobias

    Nigel Cunningham’s picture

    I do have Postfix support working, using basically the same script that's used in the exim directory.

    My diff (not cleaned up, sorry) is currently:

    # diff -u exim_og_mailinglist/og_mailinglist_exim4_transport.php postfix_og_mailinglist/og_mailinglist_postfix_transport.php 
    --- exim_og_mailinglist/og_mailinglist_exim4_transport.php	2010-10-04 02:32:40.000000000 +0000
    +++ postfix_og_mailinglist/og_mailinglist_postfix_transport.php	2010-10-15 09:19:39.000000000 +0000
    @@ -1,23 +1,30 @@
     #!/usr/bin/php
     <?php
     
    -// Reads in raw email off the STDIN and posts the email using our curl command for the appropriate site.
     
    +include_once('includes/bootstrap.inc');
    +include_once('includes/module.inc');
    +// Reads in raw email off the STDIN and posts the email using our curl command for the appropriate site.
    +$raw_email = '';
     // Grab the raw email message from stdin.
     $fd = fopen("php://stdin", "r");
     while (!feof($fd)) {
       $raw_email .= fread($fd, 1024);
     }
     
    -// Set command line arguments (sent by the exim4 transport) to variables.
    -$mail_domain = $argv[1];
    +// Set command line arguments (sent by the postfix transport) to variables.
    +$parts = explode("@", $argv[1]);
    +$mail_username = $parts[0];
    +$mail_domain = $parts[1];
     
     // Load site info
     require_once('site_info.php');
     $sites = og_mailinglist_site_info();
     
    +
     $post_url = "";
     $validation_string = "";
    +// look for mail domain in site_info.php
     foreach ($sites as $domain => $info) {
       if (strtolower($mail_domain) === $domain) {
         $post_url = $info['post_url'];
    @@ -26,7 +33,8 @@
     }
     
     if (empty($post_url)) {
    -  echo "Could not match the email domain with a Drupal site. Check that you've setup site_info.php correctly.";
    +  echo "Could not match the email domain $mail_domain with a Drupal site. Check that you've setup site_info.php correctly.";
    +
       exit();
     }
     
    @@ -42,8 +50,11 @@
     $data = array(
       'message' => $raw_email,
       'token' => $token,
    +  'group_name' => $mail_username,
     );
     
    +
    +
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     
     //make the request
    

    That is, I currently have postfix sending the whole original address, and I have the added group parameter that I put in when testing for that other bug.

    By using ${mailbox} and ${domain} instead of ${original_recipient} in the pipe command in master.cf, I could avoid the explode and make it compatible with exim & qmail.

    kyle_mathews’s picture

    Modifying ogm to work w/ multiple lists at once would be great... except it'd open a whole 'nuther set of problems. If you want to start working on that, open another issue and we can discuss more there.

    Looks like things are coming along great with the Postfix integration!

    kyle_mathews’s picture

    Nigel/Darrell, is this code ready to be added? I'd like, for the next beta release, to add support for both Postfix and cPanel. I haven't paid too close attention to this thread nor the code but I'll trust you guys that when you say it's ready I'll add it.

    Nigel Cunningham’s picture

    Hey Kyle :)

    My code is so close to what you already have for exim. I reckon we should be able to have one script that works with all mailers. What do you guys reckon?

    spencerfromsc’s picture

    Been following this thread for a while and I'm very pleased to see that Postfix integration appears to be coming along so nicely. I was just wondering if anyone has been able to get it to work in a multi-site setup with mysql storing the data. I think I've finally got aegir and postfix running smoothly, now I'd like to try to get og_mailinglist integrated with drupal commons on a few test sites, but I wanted to see if anyone had had success with this type of solution yet. Thanks.

    Nigel Cunningham’s picture

    I have Postfix using MySQL for account info and authentication (via Dovecot & PAM-MySQL), and have multiple subdomains in use. Is that the sort of thing you're after?

    spencerfromsc’s picture

    Yep...I'm basically running the same setup, managing it with postfixadmin. Any help you offer with the install process would be greatly appreciated. Since I'm basically the test subject for your typical Idiot's Guide, any steps I don't have to figure out on my own can save me a huge amount of time.

    Thanks for everyone's work on this project ,by the way, particularly Kyle. I think it has a huge amount of potential.

    kyle_mathews’s picture

    @Nigel -- if it's possible to get all the scripts aligned, then I'm for it. But I don't think it's overly important if it causes difficulties.

    kyle_mathews’s picture

    Nigel - could you create a directory with all the files needed for the postfix integration along with some instructions in an INSTALL.txt? There's some people asking for help with installing ogm on Postfix + I'll need to see everything together in order to evaluate the code / commit it.

    Let's not worry about having only one MTA script for now. Let's get something committed and available for use before worrying about prettying things up or enforcing DRY.

    Nigel Cunningham’s picture

    Okay. I've got care of my 2 year old today, but I'll try to get it done today anyway.

    Nigel Cunningham’s picture

    Just an update: I've started this (it's really just writing documentation), but not gotten it finished. I should be able to complete it tomorrow.

    Nigel Cunningham’s picture

    Sorry for the delay. Here's a git patch with the documentation I've written. As you'll see from it, I think we can just use the exim script, though I would like to see the exim script updated to support the new method of passing the original recipient (I'll submit a patch for that separately).

    Please also find attached some updates to the main INSTALL.txt.

    Nigel Cunningham’s picture

    Assigned: DarrellDuane » Nigel Cunningham
    Status: Needs work » Needs review
    kyle_mathews’s picture

    Status: Needs review » Needs work

    Nice work on the patches Nigel!

    I've committed the changes to the INSTALL.txt file with some modifications (https://github.com/KyleAMathews/og_mailinglist/commit/403ab9f4897fa1ad47...)

    On the Postfix installation documentation. I'd rather it not tell people to use the exim_og_mailinglist folder/files of a specific Drupal install. One reason is imagine a server running multiple Drupal sites running og_mailinglist. It seems odd to tie the multiple OG Mailinglist installs to one Drupal site. Plus what if someone where to delete the files of the Drupal site where Postfix was setup?

    It'd be much simpler and cleaner I think if the instructions just had people copy all the needed files to some postfix_og_mailinglist folder within the Postfix configuration folder. For exim, for example, the instructions tells people to copy the whole exim_og_mailinglist folder to /etc/exim4. I think this also makes sense as this part of OGM is a modification of the MTA not Drupal so the code should be placed wherever MTA "modules" go not where Drupal modules go. We just ship the code with the module to make installation simpler.

    Does this make sense? And fit with how Postfix works (which I have fairly minimal knowledge)?

    Nigel Cunningham’s picture

    Copying the files elsewhere is certainly doable, and I don't mind suggesting that the user do that. It would work just fine with Postfix.

    It seems to me that whatever you do, it's going to involve some degree of messiness. If you leave files in the og_m directory, you need to copy updated versions elsewhere. If you leave the files there, you need to preserve site_info.php during upgrades. Perhaps a good compromise would be to have a directory in (eg) /etc/postfix that contains site_info.php, with symlinks to the files in sites/all/modules/og_mailinglist.

    PS: It's Cunningham, not Cummingham (commit message) - I'm just starting to look at the commit itself now.

    kyle_mathews’s picture

    I don't think copying is that big of deal as the MTA integration scripts should rarely if ever change. Their job is pretty simple, POST the email to site.com/og_mailinglist. That's about as set in stone as anything is in OG Mailinglist. So once someone gets the integration working, they never would have to upgrade things on the MTA side. Even if we think of ways to improve the integration scripts, those changes will be optional, not necessary.

    Sorry about the typo.

    Nigel Cunningham’s picture

    Status: Needs work » Active

    Should this be marked as fixed now?

    kyle_mathews’s picture

    No, I haven't committed the Postfix installation instructions. The instructions haven't been modified yet per #41 and #43.

    Nigel Cunningham’s picture

    Oh, sorry. Based on the first bit of #41, I assumed you'd made the changes you wrote about as you committed it. I'll get on to that shortly.

    Nigel Cunningham’s picture

    Okay. I've just pushed a commit to my repo that provides updated instructions, as per your feedback. The repo also includes my latest Sendmail dependency removal work. Would you take a look, please? (You can find it on Githib, as a fork of your code).

    kyle_mathews’s picture

    Awesome! Thanks so much Nigel, Darrell, and everyone else that contributed! This is worthy of another release! A lot of people use Postfix so it'll be good to get it into another release. I probably won't get to it until after the (US) holidays but really appreciate all your work.

    Two commits:
    https://github.com/KyleAMathews/og_mailinglist/commit/942d50c8870004f062...
    https://github.com/KyleAMathews/og_mailinglist/commit/0f11aeaa81fc1cb304...

    kyle_mathews’s picture

    Status: Active » Fixed

    And forgot to set it as fixed.

    Status: Fixed » Closed (fixed)

    Automatically closed -- issue fixed for 2 weeks with no activity.

    kyle_mathews’s picture

    Hey folks, I'm working with a client to get OGM working with Postfix and I'm struggling to get virtual subdomains working. I want to have a catchall email for everything sent to *@lists.example.com so they can create as many groups/lists as they want without having to fiddle around with postfix settings.

    I don't really get Postfix so what I've tried might make zero sense but this is what I've got right now.

    I added this line to main.cnf per the instructions at http://www.debian-administration.org/articles/243
    virtual_alias_maps = hash:/etc/postfix/virtual

    Then in master.cnf I added the following transport:

    ogm      unix  -       n       n       -       -       pipe
      flags=FR user=nobody directory=/etc/postfix/og_mailinglist \
        argv=/etc/exim4/exim_og_mailinglist/og_mailinglist_exim4_transport.php ${domain}

    Then in /etc/postfix/virtual I added the following which I "thought" would map all incoming emails to my subdomain to the transport:
    @lists.example.com ogm

    But instead of all email coming into lists.example.com being sent to the ogm transport they were sent to ogm@example.com (not ogm@lists.example.com which I thought odd as well).

    So can anyone help me get this going? Thanks.

    kyle_mathews’s picture

    Looks like I've got things working actually. I'll post an issue tomorrow for the Postfix gurus to look over so we can add instructions for those who want to set up a catchall subdomain for group emails.

    rsbecker’s picture

    I'm really missing something here. I am using mailfix to manage mailboxes for users who have addresses associated with the domain example.com. Currently I have several lists in the form listname@example.com. I don't want to go into the postfix virtual file every time a list is added, so it appears what I need is to add this to the /etc/postfix/transport file:

    @groups.example.com organic_groups:

    I then need to add this at the bottom of the master.cf file:

    organic_groups unix - n n - - pipe -v
    flags=FR user=group:user directory=/etc/postfix/og_mailinglist \
    #argv=/etc/postfix/og_mailinglist/og_mailinglist_postfix_trhansport.php ${domain}

    I then have the site_info.php as:

    <?php

    /*
    * @return array of sites w/ associated POST urls.
    */
    function og_mailinglist_site_info() {
    return array (
    'example.com' => array(
    'post_url' => 'http://www.example.com/og_mailinglist',
    'validation_string' => 'String',
    ),
    );
    }

    Then run postman on /etc/postfix/transport and I reload postfix
    Have I missed anything yet?

    Now, because I'm using mailhandler I need to have a user that is a member of the group and a subscriber to the list. So I create a user called groupy and use mailalias to make groupy@example.com point to groupy@@groups.example.com.

    But emails are being rejected because Postfix says:

    Recipient address rejected: User unknown in virtual mailbox table

    Obviously I'm missing something, but I cannot figure out what it is.

    Nigel Cunningham’s picture

    IIRC, in addition to the above, you need to add to virtual_alias_maps or virtual_mailbox_maps (the later?) an entry that uses mysql to define the addresses from the database. I haven't done this myself yet (I'm intending to, but my implementation of OG mailing list has been held up by a failure to get spaces/features/context working the way I want).

    rsbecker’s picture

    I have all that. Used the following process to set up mailfix

    http://www.howtoforge.com/drupal-plus-postfix-integration-under-ubuntu-8.04

    greg.1.anderson’s picture

    Category: feature » support
    Status: Closed (fixed) » Active

    Do any of you postfix gurus have time to help me with my config? Following the instructions above, everything is working great when I send email from the server running postfix, but I get 554 554 5.7.1 <listname@group.site1.org>: Relay access denied (state 14) when I try to send from an external host.

    My transport looks like this:

    group.site1.org ogm_hook
    group.site2.org ogm_hook
    

    The ogm_hook entry in my master.cf looks like this:

    ogm_hook  unix  -       n       n       -       -       pipe
      flags=FR user=nobody directory=/etc/postfix argv=/etc/postfix/og_mailinglist_postfix_transport.php ${recipient} ${domain}
    

    I can fix this problem by adding an entry to my virtual map:

    groupname@site1.org		@group.site1.org
    

    With this configuration, I can successfully send to groupname@site1.org rather than groupname@group.site1.org, and the message is accepted. However, this seems to negate the reason for setting up a transport, as I now have to modify a new entry to the virtual map every time a new group is added, just as in the simpler technique of groupname: "|/etc/postfix/og_mailinglist_script.sh ${DOMAIN}".

    Am I missing something here? Is there any way to set up a transport mechanism such that postfix will allow external entities to send to it without giving 'relay access denied', and without having to modify postfix configuration files when a new group is added? I realise that postfix is just trying to help prevent me from becoming an open spam relay, but since og_mailinglist will correctly reject non-member email addresses on mail sent to @group.site1.org, I would like to turn off this protection for just this one domain. I can't seem to find a way to do that without subverting the "no additional setup" requirements.

    kyle_mathews’s picture

    Is there anything left to do on the Postfix integration? If not, I'll set it closed.

    greg.1.anderson’s picture

    I re-opened as a support request. If no one has any thoughts / guideance on #56, you can re-close it. :(

    rsbecker’s picture

    I was involved in this thread a long time ago but abandoned attempts to use og_mailinglist because I couldn't figure out how to configure it for my needs. Recently I had a server crash and had to reinstall and configure postfix, and I am interested in trying again. But the issue raised in #56 is significant.

    My setup uses a combination of sql lookups to the drupal database for user names and passwords. It would seem that that a mailfix_mailboxes table or the mailfix_domains table could be used as the virtual map which would be invoked in main.cf with

    virtual_mailbox_maps = mysql:/etc/postfix/drupal_virtual_mailbox_maps.cf

    Unfortunately, I do not have the skills to do this myself.

    aireworth’s picture

    This is an issue of virtual wildcard subdomains. I haven't looked at this much, but postfix can be setup to collect mail directed to any subdomain of (for example) site1.org and send it to a single user. As I understand it, it requires the use of regex in the virtual mailbox domains file and the virtual mailbox maps file. See step 3 of this post for an example. Replace example.com with your own domains, map to the user you've set the transport up for (instead of vmail).

    I've not tried this, there may be other ways to do this (virtual alias maps for a real user instead of virtual mailbox maps for exmple) and regex is a complete mystery to me. I'll look into it a little more and report back if there's an easier way. This of course sends all the mail to your domain to the single user setup for your transport, so if there's other mail coming to it that needs to be mapped to the proper recipients.

    Colin

    mahfiaz’s picture

    I would love to hear back if these instructions actually work: http://drupal.org/node/1848132
    Can someone please test it? These probably would cover the needs of most users.

    markbannister’s picture

    I was able to get any email addresses working following (http://drupal.org/node/1848132) by using postfix regular expressions for virtual mailboxes.
    HUGE CAVEAT!!!!!!!!!!!!!!!

    I DON'T KNOW WHAT I AM DOING IN POSTFIX

    I'll fill in more details as hash through this. I stole greatly from http://www.sympa.org/faq/postfix_howto as well.
    Basic theory:
    You add regular expression mapping to your mailbox and your transport.
    Make a file regexp_aliases and with a regular expression for the emails you are using:
    (I created a subdomain in my dns files called groups to use for email for og groups)

    #  reg match                               where to send
    /^.*@groups.example.com$/  @groups.example.com

    This will match any address coming to something@groups.example.com. Seems redundant but this keeps postfix from giving you the address not found message.
    also create a file regexp_transport with this entry
    /^.*@groups.injection-moldings.com$/ og_mailinglist:

    in your main.cf append the regexp maps to the virtual_alias_maps directive. Create the entry if required with just the regexp portion of the statement.
    virtual_alias_maps = mysql:/etc/postfix/mysql_alias.cf, regexp:/etc/postfix/regexp_aliases
    append or create the transport entry as well
    transport_maps = regexp:/etc/postfix/regexp_transport

    update Postfix using postmap

    sudo postalias /etc/postfix/regexp_aliases
    sudo postmap /etc/postfix/regexp_transport

    (This will create two files regexp_aliases.db and regexp_transport.db)
    reload postfix
    sudo postfix reload

    You should be good to go. Test, tail your mail log (sudo tail-f /var/log/mail.log), all that good stuff.

    I keep my postfix content in mysql. What I don't know how to do is put the regexp stuff in mysql.

    mahfiaz’s picture

    Title: Postfix Support. » Postfix Support
    Issue summary: View changes