Integrating Dada Mail into other Programs

Integrating Dada Mail with other programs


These below ideas are all over the board, so don't expect one, simplified, normalized way of accessing the stuff that Dada Mail does.

This, hopefully, will be something created in the future, but! Until then, here are a few ideas to get you started to solve some of the most common ways you may want to hook Dada Mail into another program.

Automatic Logging into the list control panel

The login/session system of Dada Mail is based on some sort of session information that's saved on the server side and a cookie that resides on the client's web browser.

It's slightly awkward to re-implement such a system from another program, yet it honestly *could* be done.

A pre-filled out form

An easier way, if all you want to do is to, say, have a button in another program's control panel that let's you go right to the Dada Mail list control panel is to pre-fill in the form fields required. A simple, already filled in form would look like so:

<form action="" method="post">

  <input type="hidden" name="flavor"              value="login" />
  <input type="hidden" name="process"        value="true" />
  <input type="hidden" name="admin_list"     value="yourlist" /> 
  <input type="hidden" name="admin_password" value="yourpassword" /> 
  <input type="submit"                       value="Log Into Your Dada Mail!" /> 

And that's all there really is to it. Breaking that down:

If all this information is correct, you should be able to log into the Dada Mail list.

There's one more field you can pass in this form and that is referer. If set, it'll redirect you to a specific screen in Dada Mail. For example, if you want to log in directly to the, add list control panel, add this into the form:

 <input type="hidden" name="referer" value="" /> 

Where "" is the URL to your Dada Mail.

A shortcoming to this technique is that the password required to log in will be visible in the source of the HTML you have embedded this button. Not so good.

Call the screen by mimicking a web browser

Another idea is to write a simple WWW client that'll then post the CGI parameters to Dada Mail and then print back the results. In this case, the results will return the cookie information needed to keep the session alive (or really, start the session), The refresh to the list control panel and the HTML that says, "Hey! We're logging in!":

 use strict; 
 my $Dada_Mail_URL = ''; 
 my $List          = 'yourlist'; 
 my $Password      = 'yourpassword';
 my $Referer       = ''; 
 my $F             = 'login'; 
 my $Process       = 'true';
 use CGI; 
 my $q = new CGI(
     admin_list     => $List, 
     admin_password => $Password,
     f              => $F, 
     referer        => $Referer, 
     process        => 'process', 
 use HTTP::Request; 
 use LWP::UserAgent;
 my $ua = LWP::UserAgent->new;
    $ua->agent("MyApp/0.1 ");
 my $req = HTTP::Request->new(POST => $Dada_Mail_URL);
 my $res = $ua->request($req);
 if ($res->is_success) {
     my $doc = $res->as_string;
     my ($headers, $body) = split("\n\n", $doc, 2); 
     my @header_lines = split( /\n(?!\s)/, $headers);
     for my $header(@header_lines){ 
         my ($label, $value) = split(/:\s*/, $header, 2);
         if($label =~m/(Refresh|Set\-Cookie)/){ 
             print $header . "\n";     
     print $q->header(); 
     print $body; 
 else {
     print $q->header();
     print $res->status_line, "\n";

In the above script, you'll have to fill in the first 6 variables with the correct information.

This still leaves the problem of having the password embedded in the sourcecode of the script.

Keeping the List Password Sync'd with the hosting account password

One way to get around this, is either save the password in a safer place, or keep the password sync'd with your account password.

Regardless of how you've saved the account password, you're going to need a way to fetch a clear-text (unencrypted) version of it.

Add something like this to your script that keeps all this info sync'd up:

    use DADA::MailingList::Settings; 
    use DADA::Security::Password; 
    my $ls = DADA::MailingList:Settings->new(-List => 'my_list'); 
                        -settings => {
                        password => DADA::Security::Password::encrypt_passwd('your_password'),


There's already a few ways to access Dada Mail's subscription/unsubscription API outside of the program. See:

Sending Mailing List Messages

There is an extension called, that allows you to Send a Message through a command line interface - it's designed to be easy to use from another program, regardless of what that program is written in and is based slightly (ever so slightly) on how you also use the sendmail utility.

Accessing the, "Send a Message" API

If the script isn't up your alley, you can make a very small utility script that'll bridge between your app - whatever language it's written in and Dada Mail. Here's what such an app may look like:

        # Change! The perllibs below to point to Dada Mail's perl libraries: 
        use lib qw(
        use CGI; 
        my $q = new CGI; 
        my $list = $q->param('list'); 
        if($q->param('process')) { 
        use DADA::App::MassSend; 
    my $ms = DADA::App::MassSend->new({-list => $list});
                                -cgi_obj     => $q, 
                                -html_output => 0, 
        print $q->header(); 
        print "sending is on its way!"; 
        else { 
                print $q->header() ;
                print "I don't know what you want me to do!"; 

The above example is an incredibly bare-bones idea on how to Send a Message using the DADA::App::MassSend API. Unfortunetly, the API isn't super flexible, but it can do a whole lot, if you need it to.

Save the above script as something like, send_list_message.cgi (or whatever you'd personally like). Put it into your cgi-bin/dada directory (to start) and change it's permission to, 755

The next thing you'll want to do is create an HTML page with a form that, when submitted will have the correct information to Send a Message. Here's a very small example:

        <form action="" method="post">
        <input type="hidden" name="process" value="1" /> 
        <input type="hidden" name="list" value="mylist" /> 
        <p>Subject: <input type="text" name="Subject" value="" /> </p>
        <p>PlainText Version: <br /> 
        <textarea name="text_message_body"></textarea>
        <p>HTML Version: <br /> 
        <textarea name="html_message_body"></textarea>
        <input type="submit" />

Breaking this down:

Make sure to customize the form's, action to correspond to where you're currently keeping this script and also the form field, "list" to be a valid listshortname of yours.

The form fields, Subject, text_message_body and html_message_body are named the same as the form fields located on the, Send a Message screen. Most every form field that's located in that form can be added to our example, including file attachments, partial sending options, archiving options, etc.

Our little example above only shows how to create a form that basically cicrumvents Dada Mail's own security. If you do use this form, make sure you some semblance of security is put back into your script.

Hopefully, if you're a seasoned Perl programmer, you can edit the above idea to work more closely within your own Perl program. You don't need to explicitly post to the script - all you have to do is fill out the CGI objects params, like so:

        $q->param('list', 'mylist'); 
        $q->param('process', 1); 
        $q->param('Subject', 'My Subject'); 
        $q->param('text_message_body', "This is my PlainText version!"); 
        # etc....
        use DADA::App::MassSend; 
    my $ms = DADA::App::MassSend->new({-list => scalar $q->param('list')});
                                -cgi_obj     => $q, 
                                -list        => scalar $q->param('list'), 
                                -html_output => 0, 

What if you're using another language, like php?

My advice, currently, is to call the outside script using something like php's curl support:

The idea is the same, but instead of creating an HTML form you manually submit, you pass the variables needed to the curl session and post them to the outside script.

Joomla Integration

See Bruce Scherzinger's Dada Mail Subscriptions Community Builder Plug:,com_mtree/task,viewlink/link_id,2206/Itemid,35/

Bruce says:

his Community Builder plug-in implements a bridge between Dada Mail and Joomla that allows site members to manage their subscriptions to email lists from their CB profiles. Dada Mail is a powerful open-source email list system written by Justin Simoni. Finally, real (free) email lists in Joomla!

I will eventually release a Dada Mail archive browser component for Joomla. This will allow Dada Mail to be used to implement email lists for which the only access is from within a Joomla website.

Looks Promising!

Other Examples

Dada Mail comes with a few classic Form-to-Email scripts in the, extensions directory of the distribution that are slightly tweaked to allow integration of Dada Mail. They are:



See Also

We'd also like to hear from you about future integration projects of your own. If you're working on something and need help or would simply like to announce the project, please do so:

Dada Mail Project