App::Addex::Plugin::Nobody - automatically add a recipient that goes nowhere


App-Addex-Plugin-Nobody documentation Contained in the App-Addex-Plugin-Nobody distribution.

Index


Code Index:

NAME

Top

App::Addex::Plugin::Nobody - automatically add a recipient that goes nowhere

VERSION

version 0.003

DESCRIPTION

Top

The only valid "To" header that doesn't imply delivery somewhere looks something like this:

  To: undisclosed-recipients: ;

This plugin adds a virtual entry to your address book with that address.

CONFIGURATION

Top

First, you have to add the plugin to your Addex configuration file's top section:

  plugin = App::Addex::Plugin::Nobody

You can supply the following options for the plugin:

  name  - the "full name" to use (default: "Undisclosed Recipients")
  nick  - the nick (if any) to provide (default: nobody)
  group - the name of the address group (default: undisclosed-recipients)
          this option is not well-validated, so maybe you should leave it alone

The entry will have a true skip_hiveminder field, to avoid bizarre interactions with the Hiveminder plugin.

AUTHOR

Top

Ricardo SIGNES, <rjbs@cpan.org>

BUGS

Top

Please report any bugs or feature requests through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT

Top


App-Addex-Plugin-Nobody documentation Contained in the App-Addex-Plugin-Nobody distribution.
use strict;
use warnings;

package App::Addex::Plugin::Nobody;
use 5.006; # our
use Sub::Install;

our $VERSION = '0.003';

sub import {
  my ($mixin, %arg) = @_;


  my $group_name = $arg{group} || 'undisclosed-recipients';

  require App::Addex::Entry;

  my $nobody = App::Addex::Entry->new({
    name   => $arg{name} || 'Undisclosed Recipients',
    nick   => exists $arg{nick} ? $arg{nick} : 'nobody',
    fields => { skip_hiveminder => 1 },
    emails => [
      App::Addex::Entry::EmailAddress->new({
        address  => "$group_name: ;",
        sends    => 0,
        receives => 1,
      }),
    ],
  });

  my $caller = caller;
  my $original_sub = $caller->can('entries');

  my $new_entries = sub {
    my ($self) = @_;

    my @entries = $self->$original_sub;

    return (@entries, $nobody);
  };

  Sub::Install::reinstall_sub({
    code => $new_entries,
    into => $caller,
    as   => 'entries',
  });
}

1;