NAME

Egg::Plugin::MailSend - Plugin that offers mail delivery function for Egg.

SYNOPSIS

Controller.

use Egg qw/ MailSend /;

Configuration.

plugin_mailsend=> {
  handler         => 'SMTP',
  debug           => 1,
  smtp_host       => 'localhost',
  default_from    => 'WEB-Master <master@domain.name>',
  default_subject => 'WEB-Mailer.',
  },

Example of code.

my $success= $e->mail->send(
  to=> [qw{ adder_1_@domain.name adder_2_@domain.name }],
  subject  => 'Mail subject.',
  body     => 'Mail body',
  );

if ($success) {
  print "Mail was transmitted.";
} else {
  print "Failed in the transmission of mail !!";
}

CONFIGURATION

handler

Module name used for mail delivery.

Please set the name since Egg::Plugin::MailSend.

Default is 'CMD'.

debug

It is a flag for debug mode.

default_from

Addressor address used by default. * Indispensability.

default_to

Destination address used by default.

Two or more destinations can be set by setting it by the array reference.

default_subject

Subject of mail used by default.

default_body_header

Header of content of mail used by default.

Footer of content of mail used by default.

default_return_path

Address reply error's occurring using it by default ahead.

default_reply_to

Reply_to address used by default.

default_cc

Cc address used by default.

default_bcc

Bcc address used by default.

include_headers

Additional header that wants to be inserted in header of mail.

Please set it by the HASH reference.

x_mailer

Mail delivery application name.

METHODS

my $mail= $e->mail

The object of the module set with handler is returned.

The argument is passed and it is setting revokable.

my $mail= $e->mail(
  default_from=> 'custom@domain.name',
  default_body_header=> "mail-header \n\n",
  default_body_footer=> "\n\n mail-footer",
  );

$mail->send ([PARAM])

The value of the default of Configuration can be overwrited by passing the parameter.

The following keys can be used for the parameter.

to, from, cc, bcc, reply_to, return_path, subject, body_header, body_footer, body, attach, include_headers, x_mailer
$mail->send(
  to    => 'foo@domain.name',
  cc    => [qw{ hoge@domain.name zoo@domain.name }],
  body  => 'Mail body.',
  return_path => 'error@domain.name',
  );

The value of body is used as a content of mail. * You may pass it by the ARRAY reference and the CODE reference.

The chance to make the content of mail of each destination dynamically can be done by setting the CODE reference in the content of mail.

my $count;
my $mailbody= sub {
  my($e, $mail, $to_addr)= @_;
  ++$count;
  $mail->subject("Mail No: $count");
  <<END_BODY
Mail No: $count
-------------------------------
... ban, bo, bo, bon.
END_BODY
  };

$mail->send(
  to   => [qw{ a1@domail.name a2@domail.name a3@domail.name }],
  body => $mailbody,
  );

$mail->finish ([CODE_REF])

To do some processing after Mail Sending, the CODE reference is defined beforehand.

* Finish of each To address is called.

my $mail= $e->mail;
my @mailsend;
$mail->finish( sub {
  my($e, $mail, $to_addr, $mail_body)= @_;
  push @mailsend, [$to_addr, $mail_body];
  } );
my $mail->send(
  to=> [qw{ a1@domail.name a2@domail.name a3@domail.name }],
  body => $mailbody,
  );
for (@mailsend) {
  $e->model->create({
    to_addr   => $_->[0],
    mail_body => ${$_->[1]},
    });
}

mail_encode

The controller etc. can overwrite this method, and to do peculiar processing to making mime body of mail, processing be added.

package MYPROJECT;
..
..
sub mail_encode {
  my($e, $mail, $body)= @_;
  ...
  for (@$body) {  ## $body ‚Ì’l‚Í•K‚¸ ARRAY ƒŠƒtƒ@ƒŒƒ“ƒX
    ....
  }
  return ( $mail->subject, $body, { 'X-Custum-Header'=> 'banban.' } );
}

* Egg::Plugin::MailSend::ISO2022JP for Japanese Mail Sending is enclosed. Please see and that document.

reset

The set parameter has already been initialized.

setup

For start preparation of project. Do not call it from the application.

SEE ALSO

Egg::Release, Egg::Plugin::CMD, Egg::Plugin::SMTP, Egg::Plugin::ISO2022JP,

AUTHOR

Masatoshi Mizuno <lushe@cpan.org>

COPYRIGHT

Copyright (C) 2007 by Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 342:

Non-ASCII character seen before =encoding in '‚Ì’l‚Í•K‚¸'. Assuming CP1252