Name

Bric::Util::Trans::Mail - Utility class for sending email.

Synopsis

use Bric::Util::Trans::Mail;
my $m = Bric::Util::Trans::Mail->new(
  { smtp    => 'mail.sourceforge.net',
    from    => 'bricolage-devel@lists.sourceforge.net',
    to      => ['joe@example.com'],
    subject => 'Greetings',
    message => 'This is a message sent via Bric::Util::Trans::Mail'
   });
$m->send;

Description

This class provides a thin abstraction to the MIME::Entity and Net::SMTP modules. Use it to send email from within Bricolage applications. Or from within other applications. We don't care.

Interface

Constructors

my $mail = Bric::Util::Trans::Mail->new($init)

Instantiates a Bric::Util::Trans::Mail object. An anonymous of initial values may be passed. The supported intial value keys are:

Throws:

Side Effects: NONE.

Notes: NONE.

Destructors

$org->DESTROY

Dummy method to prevent wasting time trying to AUTOLOAD DESTROY.

Throws: NONE.

Side Effects: NONE.

Notes: NONE.

Public Class Methods

NONE.

Public Instance Methods

my $smtp = $mail->get_smtp

Returns the DNS name of the SMTP server to which to send email.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $mail->set_smtp($smtp)

Sets the DNS name of the SMTP server to which to send email.

Throws:

Side Effects: NONE.

Notes: NONE.

my $from = $mail->get_from

Returns the email address the message is to be sent from.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $mail->set_from($from)

Sets the email address from which to send the email.

Throws:

Side Effects: NONE.

Notes: NONE.

my $to_aref = $mail->get_to

Returns an anonymous array of email address to which to send the mail.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $mail->set_to($to_aref)

Sets the list of email addresses to which to send the mail. Pass in the list as an anonymous array.

Throws:

Side Effects: Parses out the one or more email addresses in each item in the array reference to use as the recipients. The string in each item will be used literally in the "From" header of the outgoing email. To change the recipients, pass in a new array reference rather than edit the existing array reference.

Notes: NONE.

my $cc_aref = $mail->get_cc

Returns an anonymous array of address to which to Cc the mail.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $mail->set_cc($cc_aref)

Sets the list of email addresses to which to Cc the mail. Pass in the list as an anonymous array.

Throws:

Side Effects: Parses out the one or more email addresses in each item in the array reference to use as the recipients. The string in each item will be used literally in the "Cc" header of the outgoing email. To change the recipients, pass in a new array reference rather than edit the existing array reference.

Notes: NONE.

my $bcc_aref = $mail->get_bcc

Returns an anonymous array of address to which to Bcc the mail.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $mail->set_bcc($bcc_aref)

Sets the list of email addresses to which to Bcc the mail. Pass in the list as an anonymous array.

Throws:

Side Effects: Parses out the one or more email addresses in each item in the array reference to use as the recipients. To change the recipients, pass in a new array reference rather than edit the existing array reference.

Notes: NONE.

my $sub = $mail->get_content_type

Returns the content type of the mail. Defaults to "text/plain" if unspecified.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $mail->set_content_type($sub)

Sets content type of the email.

Throws:

Side Effects: NONE.

Notes: NONE.

my $sub = $mail->get_subject

Returns the subject of the mail.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $mail->set_subject($sub)

Sets subject of the email.

Throws:

Side Effects: NONE.

Notes: NONE.

my $msg = $mail->get_message

Returns the message (body) of the email.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $mail->set_message($msg)

Sets message (body) of the email.

Throws:

Side Effects: NONE.

Notes: NONE.

my $resources_aref = $mail->get_resources

Returns an anonymous array of Bric::Dist::Resource objects representing files to send as attachments. Returns undef if no resources are to be attached.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $mail->set_resources($resources_aref)

Sets the anonymous array of Bric::Dist::Resource objects representing files to send as attachments.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $mail->send
$self = $mail->send($debug)

Sends the email to the addresses stored in to, cc, and bcc. Pass in a true value in order to get debugging statements from Net::SMTP. This is useful to see excactly what's happening when you send email.

Throws:

Side Effects: NONE.

Notes: NONE.

Private

Private Class Methods

NONE.

Private Instance Methods

NONE.

Private Functions

NONE.

Notes

NONE.

Author

David Wheeler <david@justatheory.com>

See Also

Bric, Bric::Dist::Resource, Bric::Dist::Action::Email, Net::SMTP, MIME::Entity