Question
I have a small group of registered users who would like to be able to send e-mails to everyone in their group easily. Is there a way to add an "e-mail group" link that would automatically create a mailto link with each member's e-mail address in it?
To clarify, I don't want the users to be able to actually send the mail through TWiki, but instead want them to be able to get all the addresses they need to send the message to from TWiki.
Update March 19, 2005: I've found, in TWiki.pm, that there's a function "getEmailOfUser( $wikiName )" which returns either the e-mail of a single user or the e-mail list of a group. Is there any way to call this function from a TWiki page?
Environment
--
MarcPerkins - 11 Mar 2005
Answer
No, and I really
really wouldn't recommend it anyway.
There are various applications that send mail -
NotificationPlugin,
MailerContrib,
ActionTrackerPlugin - any of which may answer your requirement.
If all you want are email addresses, write a %SEARCH to find them in user's home topics e.g. %SEARCH{ "\s+\* Email:" type="regex" web="Main" ...
--
CrawfordCurrie - 23 Mar 2005
I want users to be able to get the e-mail addresses of everyone in a specific group, and then use another e-mail program to send the group messages; thus the various notification plugins don't help me (unless I'm missing something).
The search option is a good start, thanks. However, is there a way to limit the search so that it only returns only the e-mails of members of a specific group rather than every user on the site?
--
MarcPerkins - 10 Apr 2005
I believe this missing feature would be very useful for some
TWikiApplications.
--
PeterThoeny - 11 Apr 2005
Hello Marc, have you found a solution yet? I would be interested, too.
What I figured so far is:
%SEARCH{"GROUP" web="Main" topic="*Group" casesensitive="on"
nosummary="on" nosearch="on" noheader="on" nototal="on"
format=" * Main.$topic members: $n * $pattern(.* \* Set GROUP =([^\n]*).*)$n "}%
will return a nice list of the existing groups and their members (with very slight changes to the example given in
Main.TWikiGroups).
%SEARCH{ " \* Email: " type="regex" web="Main" nosearch="on" nototal="on"
format="$pattern(.*?\*.*?Email\:\s*([^\n\r]+).*)" separator="; "}%
will list every first occuring Email address in any topic of the Main web (search pattern taken from
TWiki.FormattedSearch).
So what we need now is probably a nested search combining these two. But all my attempts were unsuccessful. May be someone else might be able to help? Cheers.
--
JuditMays - 12 Apr 2005
future note Bare in mind that
DakarRelease moves user data off
BulletedLists and in to
FormData. This means searches that search for bullets in Main, such Judit's latter one, will cease to work.
--
MartinCleaver - 12 Apr 2005
Judit - I hadn't made much progress, but now that I've seen your searches I've made some progress.
I now have a search that now returns the list of any one group's members (replacing NameOfGroup with whatever group you're searching for):
%SEARCH{"GROUP" web="Main" topic="NameOfGroup" casesensitive="on"
nosummary="on" nosearch="on" noheader="on" nototal="on"
format="$pattern(.*Set GROUP =([^\n]*).*)$n "}%
That output can then be formatted as a regular expression OR search, which can theoretically be used as the input to a second search function (limited to the titles of the pages) which pulls the e-mails out of all the user pages of the group members.
Here's the code to format the group-member search output as a regular expression OR search:
(%CALC{"$SUBSTITUTE($SUBSTITUTE($TRANSLATE(%SEARCH{"GROUP" web="Main"
topic="NameOfGroup" casesensitive="on" nosummary="on" nosearch="on" noheader="on"
nototal="on" format="$pattern(.*Set GROUP = ([^\n]*).*)"}%,$comma,|),| ,|),Main.,)"}%)
Unfortunately, however, adding that bit of code to the search="" field of a second search causes an error, since the first search sees the %} of the %CALC% function as the end of the first %SEARCH%.
Thus, while the code below (with manually entered user names) works, replacing the regular expression of the user names with the function above breaks the function.
%SEARCH{search="(UserOne|UserTwo|UserThree)" scope="topic" type="regex" web="Main"
nosearch="on" nototal="on" format="$pattern(.*?\*.*?Email\:\s*([^\n\r]+).*)"}%
This problem has been documented
here
, and I'm not sure how to get around it. All my workaround attempts have failed.
I hope this helps ...
--
MarcPerkins - 17 Apr 2005
Interesting subject

Isn't part of the problem, that the "order of execution" can't be solved? I.e. we want the inner loop (and
CALC) to be executed first, and then use that as a parameter to the outer search - but this kind of construction is not supported by TWikis engine (yet)?
I think this functionality needs to be implemented in a plugin (good) or in the TWiki core (better - either by creating a new tag or by adding support for searches within searches).
Still, Crawfords suggestion on using the existing plugins aren't bad either - let's not forget part of TWiki's mission
is related to relieving some of those loaded corporate mailboxes
--
SteffenPoulsen - 18 Apr 2005
I got this to work but I had to install
TopicVarsPlugin and configure it as the first plugin to execute.
%SEARCH{"(%CALC{"$SUBSTITUTE($SUBSTITUTE($TRANSLATE(%Main.YOURGROUP.GROUP%,$comma,|),| ,|),Main.,)"}%)" web="%MAINWEB%" scope="topic" type="regex" nosearch="on" format="..."}%
Thanks for the $Translate and $Substitute code, I was lost without those.
--
ChadBoulay - 07 Jun 2006
I'm afraid that none of these methods will work in TWiki04 since the emails are now stored in
.htpasswd . Any one have any ideas how this could be done now since it is a pretty basic administrative need?
--
LynnwoodBrown - 08 Jun 2006
I've submitted the following
FeatureRequest:
ProvideMechanismToSendEmailsToRegisteredUsers.
--
LynnwoodBrown - 08 Jun 2006
Since we work on an intranet, and email security is not an issue, I Wrote a very simple plugin to do this:
# =========================
sub commonTagsHandler {
debug("- ${pluginName}::commonTagsHandler( $_[2].$_[1] )");
$_[0] =~ s/%SENDEMAIL%/&_makelink($_[2], $_[1])/ge;
}
sub _makelink {
my ($web, $topic) = @_;
my $user = $TWiki::Plugins::SESSION->{users}->findUser($topic, $topic, 1 );
my $emails = join(';', $user->emails());
# my $emails = TWiki::Func::wikiToEmail($topic);
return '' unless $emails;
$emails =~ s/,/;/go;
return '<span class="twikiButton"><a href="mailto:' .$emails .'" class="dmtcMailLink">Mail to !' .$topic .'</a></span>';
}
This just creates a button on whatever user or group page it is on to mail to the user or all members of the group using the client-side mail program
This plugin will use whatever emails are registered to the users - in our case it uses the ones from the .htpasswd file.
BTW - I couldn't get
wikiToEmails() to work for some reason.
--
DarrenElkerton - 25 Jan 2007
Many TWiki users, being corporate users, likely already have email groups set up in their mail clients for mailing internal groups. It might be even more valuable to be able to create a link or button that would send an email addressed to numerous external addresses. I'm thinking of a project's contact list, divided by function. You could click a link to address a new email to all email addresses within that part of the list. This would be easy to maintain even as just manual entry in the page code. In fact, you can almost get there:
mailto:address1@company.com, address2@company.com . The problem is that as soon as you add a third email address, the whole thing breaks. TWiki renders the second one in the list as
a href... /a and the resulting email is useless. Does this indicate a problem with how TWiki is rendering the HTML? Or does it present a possibility of an easier fix (or way to do this)?
--
DavidWolfe - 25 Sep 2007
It is possible to construct a mail URL addressing multiple recepients.
Example:
sample group
Written as:
<a href="mailto:address1@example.com,address2@example.com?This+is+the+subject">sample group</a>
The list of addresses can be supplied by a
SEARCH.
--
PeterThoeny - 25 Sep 2007