Community Documentation

Setting OG Mailinglist up the hard way using MTA

Last updated May 18, 2013. Created by mahfiaz on November 22, 2012.
Edited by markbannister, betz. Log in to edit this page.

The easier way to set up OG Mailinglist is to use MailGun.com services. For some people this doesn't cut it, so here is the hard way.

Exim4

This is pretty much a copy of the following file:
http://drupalcode.org/project/og_mailinglist.git/blob_plain/refs/heads/7...

Go to sites/all/modules/og_mailinglist/backends/exim_og_mailinglist directory.

  1. Copy this entire folder to /etc/exim4/

    cp -r ../exim_og_mailinglist /etc/exim4/

  2. Link or copy 950_exim4-config_drupal_og_mailinglist_router to /etc/exim4/conf.d/router/950_exim4-config_drupal_og_mailinglist_router

    ln -s \
    /etc/exim4/exim_og_mailinglist/950_exim4-config_drupal_og_mailinglist_router \
    /etc/exim4/conf.d/router/950_exim4-config_drupal_og_mailinglist_router
  3. Link or copy 95_exim4-config_drupal_og_mailinglist_transport to /etc/exim4/conf.d/transport/95_exim4-config_drupal_og_mailinglist_transport

    ln -s \
    /etc/exim4/exim_og_mailinglist/95_exim4-config_drupal_og_mailinglist_transport \
    /etc/exim4/conf.d/transport/95_exim4-config_drupal_og_mailinglist_transport
  4. Copy example.site_info.php to site_info.php

    cp /etc/exim4/exim_og_mailinglist/example.site_info.php \
    /etc/exim4/exim_og_mailinglist/site_info.php
  5. Adjust settings in site_info.php file. Read on how to set up site_info.php file.

    nano /etc/exim4/exim_og_mailinglist/site_info.php

  6. Run dpkg-reconfigure exim4-config on Debain/Ubuntu systems and ensure that the "Other destinations for which mail is accepted:" or "local domains" setting includes your site's domain name. Otherwise, Exim will simply reject emails directed to this domain.

    Also allow exim4 to recieve mail from wilderness, set "IP-addresses to listen on for incoming SMTP connections" to be blank, otherwise only listed hosts can send you email.

  7. Restart exim by running /etc/init.d/exim4 restart

    Note that on some operating systems like Debian, you need to run update-exim4.conf.template to actually update the configuration before restarting. See your installation's Exim documentation for specifics.

  8. Test setup by sending email to a test group's email on your site, e.g. test-group@example.com

Debugging help for when things don't work:
SSH into your server, run "tail -f /var/log/exim/mainlog" to see that emails are actually reaching your server and that the og_mailinglist router/transports are being called. Also, it might help to look at the Drupal logs at admin/reports/dblog

Testing

To test this script you could invoke it from command line as follows (when inside the og_mailinglist directory; you also need to adjust domain to match your Drupal installation):
/etc/exim4/exim_og_mailinglist/og_mailinglist_debug.sh example.com < testing/applemail

Postfix

This is pretty much a copy of the following file:
http://drupalcode.org/project/og_mailinglist.git/blob_plain/refs/heads/7...

Set up scripts

  • Enable postfix access to og_mailinglist_postfix_transport.php, copy entire sites/all/modules/og_mailinglist/backends/postfix_og_mailinglist folder to /etc/postfix/

    cp -r ../postfix_og_mailinglist /etc/postfix/

  • Copy example.site_info.php to site_info.php and make it's
    contents match your installation. Read on how to set up site_info.php file.

    cp /etc/postfix/postfix_og_mailinglist/example.site_info.php \
    /etc/postfix/postfix_og_mailinglist/site_info.php

    Set up Postfix

    There are two ways to accomplish this. You could either use a pipe command (the easier way) or if you define your email addresses e.g using MySql database, you could use the transport map (the slightly harder way). You should not use both of these at once.

    Pipe command

    To set up an alias address in a virtual domain, using a pipe command, add it to your Postfix alias file /etc/aliases (as is often done for Mailman addresses):

    @example.com "| /etc/postfix/postfix_og_mailinglist/og_mailinglist_postfix_transport.php ${DOMAIN}"

    Or if you prefer not to use catchall address:

    test:      "| /etc/postfix/postfix_og_mailinglist/og_mailinglist_postfix_transport.php ${DOMAIN}"

    When debbugging, you could temporarily use this one (writes mails and errors to /tmp):

    test:      "| /etc/postfix/postfix_og_mailinglist/og_mailinglist_debug.sh ${DOMAIN}"

    Transport map

    Instead of using a simple Mailman type pipe to a command, it is also possible to define email addresses in the normal way, then use a special transport to handle delivery. You might want to do this if you define a good portion of your addresses via MySQL.

    • Add a line to your virtual map, it might thus look like this:

      test@example.com @groups.example.com

    • Add transport map, so Postfix knows how to deliver email (/etc/postfix/transport):

      test@groups.example.com og_mailinglist:

    • Add the transport command to /etc/postfix/master.cf to define the 'og_mailinglist' transport. If you use "direct_posting" method, set the user=mail:www-data or similar, so it has permissions necessary to read drupal files, especially sites/default/settings.php

      The command might look like this:

        flags=FR user=nobody directory=/etc/postfix/postfix_og_mailinglist \
          argv=og_mailinglist_postfix_transport.php ${domain}

      Complete entry example (directory does not seem to work in ubuntu):
      og_mailinglist  unix  - n n - - pipe -v
      flags=FR user=nobody  argv=/etc/postfix/postfix_og_mailinglist/og_mailinglist_postfix_transport.php ${domain}

      -v at end of first line gives you verbose output in the mail log

    Testing

    To test this script you could invoke it from command line as follows (when inside the og_mailinglist directory; you also need to adjust domain to match your Drupal installation):
    /etc/postfix/postfix_og_mailinglist/og_mailinglist_debug.sh example.com < testing/applemail

Comments

Postfix Configuration Version 2.3.3

I'm running postfix 2.3.3, and had to make the following changes in order to get it working. I'm by no means a postfix guru (sort of flying blind here), but in case it helps someone else, these are the changes I had to make:

  • Add alias for the group email address (I know I'm just aliasing it to itself, but that worked):
    test@example.com test@example.come
  • Add rule to the transport file:
    test@example.com og_mailinglist:
  • Add the transport file to /etc/postfix/main.cf (Probably obvious, but I didn't know)
    transport_maps = hash:/etc/postfix/transport
  • Add the the transport command to master.cf. ${domain} was not defined, so I used ${nexthop} instead. Also, the directory command did not work, so I had to spell out the directory
    flags=FR user=mail:apache argv=/etc/postfix/postfix_og_mailinglist/og_mailinglist_postfix_transport.php ${nexthop}
    That makes the full entry look like:
    og_mailinglist  unix  - n n - - pipe -v
      flags=FR user=mail:apache argv=/etc/postfix/postfix_og_mailinglist/og_mailinglist_postfix_transport.php ${nexthop}

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 7.x
Audience
Site builders
Level
Advanced

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here