NAME

MySpam::Email - Email Interface Module for the MySpam application

SYNOPSIS

use MySpam::Email;
my $e = MySpam::Email->new;

$e->reset;
$e->to($to);
$e->from($from);
$e->subject($subject);
$e->list; # or release or whitelist or subscribe ... etc
$e->send;

DESCRIPTION

MySpam::Email is for generating a MySpam email response. Various methods can be called to perform actions in the MySpam database, and the results of those actions will be formatted as an email.

The email sent is a MIME multipart/alternative mail containing both text/plain and text/html parts.

MySpam::Email is used by the myspam-smtp script.

METHODS

new($file)

Create a new MySpam::Email object. Takes an optional $file argument to specify a configuration file other than the default /etc/myspam/myspam.conf.

connect()

Internal method. Creates a MySpam object which automatically connects to the database specified by /etc/myspam/myspam.conf or the $file given to the new() method.

reset()

Resets all internal values ready for a new email to be generated. This should be called after the send() method if you want to continue to use the same object for more emails.

from($from)

Set the From: header.

to($to)

Set the To: header.

cc($cc)

Set the Cc: header.

subject($subject)

Set the Subject: header.

xbody()

Internal method. Returns the XML::API object representing the HTML part of the email.

add_to_body($text)

Internal method. Adds $text to the text/plain part of the email.

usage()

Generates a general help/usage statement.

error($msg)

Adds the text $msg to the body and includes the 'admin' address in the Cc: header.

list()

Lists the mails contained in the database for the address $to (set by the to() method). Croaks if to() has not already been called.

release($id)

Releases the mail with id $id if that mail is quarantined for to $to. Croaks if to() has not already been called.

whitelist($sender)

Adds address $sender to the whitelist for $to. Croaks if to() has not already been called.

unwhitelist($sender)

Removes address $sender from the whitelist for $to. Croaks if to() has not already been called.

unsubscribe()

Unsubscribes address $to from all subscription lists. Croaks if to() has not already been called.

subscribe(1|2)

Subscribe address $to to the subscription '1' or '2'. See myspam for the meanings of the different subscriptions.

send()

Hands off the email to the local MTA for delivery to the $to and/or $cc addresses.

FILES

/etc/myspam/myspam.conf - database connection information

/etc/myspam/myspam.css - style definition for HTML email

/var/log/mail.* - syslog(8) reporting of success or failure

SEE ALSO

myspam-smtp, myspam, MySpam

AUTHOR

Mark Lawrence <nomad@null.net>

COPYRIGHT AND LICENSE

Copyright (C) 2007 Mark Lawrence <nomad@null.net>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.