The Dada Mail New Features Fundraiser is on! Contribute and cast your vote today!
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.
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.
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=``http://example.com/cgi-bin/dada/mail.cgi'' method=``post''>
<input type="hidden" name="f" 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!" />
</form>
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="http://example.com/cgi-bin/dada/mail.cgi?f=add" />
Where ``http://example.com/cgi-bin/dada/mail.cgi'' 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.
Another idea is to write a simple WWW client that'll then post the CGI paramaters 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 t that says, ``Hey! We're logging in!'':
#!/usr/bin/perl use strict; my $Dada_Mail_URL = 'http://example.com/cgi-bin/dada/mail.cgi'; 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); $req->content_type('application/x-www-form-urlencoded'); $req->content($q->query_string()); 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); foreach 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.
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.
Then, 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');
$ls->save({
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:
There is an extension called, send_dada_mail.pl that allows you to send a list 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.
Currently, it's only shipped in the 2.11 alpha series of Dada Mail, as it's still going through development, but do check it out if you're looking for sending a list message via Dada Mail in your own program:
http://dadamailproject.com/support/documentation-dada-2_11-alpha_5/send_dada_mail.pl.html
See Bruce Scherzinger's Dada Mail Subscriptions Community Builder Plug:
http://joomlander.net/index.php
http://extensions.joomla.org/component/option,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!
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:
http://dadamailproject.com/support/documentation-dada-2_10_16/Dada-ized_FormMail_README.pod.html
http://dadamailproject.com/support/documentation-dada-2_10_16/Dada-ized_TFMail_README.pod.html
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 on the boards:
http://dadamailproject.com/support/boards/index.php
And/or the dadadev mailing list
http://dadamailproject.com/cgi-bin/dada/mail.cgi/list/dadadev/
Dada Mail is Free Software and is released under the Gnu
Public License.
Dada Mail is written in Perl because we love Perl.