Gossamer Forum
Home : Products : Gossamer Links : Discussions :

How to send one email per link owner

Quote Reply
How to send one email per link owner
I just tested sending out an email to link owners (All Links) and I see one email is sent per link.

I can understand why that would be the general purpose default as it allows link specific info to be sent in each email.

But quite commonly I'd expect to send email to link owners about a change, update etc that is relevant to them as link owners - and wouldn't want them to receive dozens of copies of the same message if they own multiple links.

How can I send just one per link owner?

Searching the forum, I can't see an answer for this. I saw a suggestion to email "Users" rather than "Links" but surely Users includes people who have registered to rate, review, etc and are not necessarily link owners?

Thanks

Stewart
Quote Reply
Re: [CrazyGuy] How to send one email per link owner In reply to
I found an old (2002) post from Alex which says:
Quote:
You can send to LinkOwners instead of Links, and this will send one email per unique email address.

That's exactly what I want to do )surely almost everyone wants to do?) so now I'm wondering if I'm really missing something. On my email menu I can email:
All Users
All Links
Selected Users
Selected Links

Where does the reference to "LinkOwners" fit into this?

Thanks

Stewart

Quote Reply
Re: [CrazyGuy] How to send one email per link owner In reply to
Unfortunately, to send a single e-mail per link owner currently would require some code changes (with some Perl knowledge, it shouldn't take too much work to change an existing function to do it). I'll add this to our possible future features list.

Adrian
Quote Reply
Re: [brewt] How to send one email per link owner In reply to
OK - I think this is so essential that I'd like to take a look at changing that code.
Our setup will have a link per thing rather than per site or company so there will be a many:1 relationship for link owners.
Do you think you could point me to the area needing attention (yes, I can/will look myself, but you might be able to pinpoint it quicker).

Stewart
Quote Reply
Re: [CrazyGuy] How to send one email per link owner In reply to
admin/Links/MassMailer.pm is where all the mass mail code is.

Adrian
Quote Reply
Re: [CrazyGuy] How to send one email per link owner In reply to
I get around this by running a script like this which sets a flag in the users table and then I just filter out users with that flag when sending emails. Not the ideal solution but it gets the job done.

Code:

my $cond = GT::SQL::Condition->new( 'Username', '!=', 'admin' );
my $sth = $users->select( $cond, ['Username','Email'] );
my $cnt = $users->count();

if ( !$cnt ) {
print "\nNo links matching criteria....";
exit;
}

while ( my ( $db_username, $db_email ) = $sth->fetchrow_array ) {

my $cnt = $links->count ( { 'LinkOwner' => $db_username } );
if ( $cnt > 0 ) {
$users->update ( { SendMail => 'Yes'}, { Username => $db_username } );
}

} # while

Regards,
Peter Puglisi
www.ausfreedom.com
Ultimate Freedom is our game.
Quote Reply
Re: [brewt] How to send one email per link owner In reply to
I'm unfortunately limited by the fact that my (reasonable) perl knowledge is very old-school. I can just about follow the new-fangled object-oriented stuff, but tend to break things if I modify it.

Seems to me that all that is required (at least for an "always-on" solution) is to add a "DISTINCT" to the mysql statements that select the records.

Code:
if ($to eq 'LINKOWNERS') {
my $email_cond = new GT::SQL::Condition;
$email_cond->add($GT::SQL::PREFIX . "Links.Contact_Email" => LIKE => '%_%');
$email_cond->add($GT::SQL::PREFIX . "Users.Email" => LIKE => '%_%');
$email_cond->boolean("OR");
$cond->add($email_cond);
$cond->add($GT::SQL::PREFIX . "Users.ReceiveMail" => 'Yes');
}

But I can't work out how to do that with this style of code.

I suppose I could just replace the appropriate clauses with some old-school code but I'd like to minimise how much of the underlying code gets customised.