NAME

Egg::Plugin::MailSend - Mail is delivered for Egg Plugin.

SYNOPSIS

use Egg qw/ MailSend /;

__PACKAGE__->egg_startup(
  .....
  ...
  plugin_mailsend => {
    default_from    => 'user@mydomain.name',
    default_subject => 'mail subject.',
    handler         => 'SMTP',
    smtp_host       => '192.168.1.1',
    timeout         => 7,
    debug           => 0,
    },
  );

# Mail is transmitted.
$e->mail->send(
  to      => 'hoge@mail.address',
  subject => 'Mail subject.',
  body    => 'Mail body',
  ) || return q{ Fails in transmission of mail. };

# The same mail is transmitted to two or more addresses.
$e->mail->send(
  to      => [qw/ hoge@mail.address foo@address /],
  subject => 'Mail subject.',
  body    => 'Mail body',
  ) || return q{ Fails in transmission of mail. };

# ARRAY is passed to the content of mail.
$e->mail->send(
  to      => [qw/ hoge@mail.address foo@address /],
  subject => 'Mail subject.',
  body    => [ $mail_header, $mail_body, $mail_footer ],
  );

# CODE is passed to the content of mail.
$e->mail->send(
  to      => [qw/ hoge@mail.address foo@address /],
  subject => 'Mail subject.',
  body    => sub {
    my($mail, $e, $to)= @_;
    my $body= ... create mail body code.
    \$body;
    },
  );

# The code that wants to be executed after it delivers by E-mail each is set.
my $mail= $e->mail;
$mail->finish_code( sub {
  my($mail, $e, $to_addr, $body_scalar_ref)= @_;
  .... code ...
  } );

$mail->send(
  to=> [qw/ hoge@mail.address foo@address boo@oo.jp /],
  .....
  ...
  );

# The setting of default is temporarily changed.
$e->mail(
  default_reply_to    => 'addr1@hhh.bo, addr2@dddd.hh',
  default_return_path => 'admin@support.gg',
  )->send(
  to => 'hoge@mail.address',
  .....
  ...
  );

DESCRIPTION

It is a plugin for E-mail delivery.

CONFIGURATION

Please set it to 'plugin_mailsend' with HASH.

handler

Name of module that becomes handler object.

# If Egg::Plugin::MailSend::SMTP is used, it is the following.
handler => 'SMPT',

It treats assuming that 'CMD' is specified when omitting it.

debug

Debug mode.

* The behavior of debug mode changes by the handler object.

default_from

Address used when from address is omitted.

default_to

Address used when to address is omitted.

default_subject

Subject used when subject is omitted.

default_body_header

Header buried under content of mail without fail.

Footer buried under content of mail without fail.

default_return_path

Error mail destination address of transmission failure.

default_reply_to

Address set to Reply_to.

default_cc

Address set to Cc header.

default_bcc

Address set to Bcc header.

include_headers

To add an original mail header, it sets it by the HASH reference.

METHODS

mail ( [SETUP_HASH] )

The handler object to do Mail Sending is returned.

If SETUP_HASH is specified, the setting of default is overwrited.

It tries to generate the object newly annulling the object before when SETUP_HASH is given though the same object uses and it is turned from now on when called once usually.

mail_encode

This method is called so that the handler object may make the chance of the adjustment of the content of mail.

It passes by the method of default usually. Please do this method in override as a controller etc. if you want to do something by this method.

For instance, the text is JIS code in the mail of Japan, and it is hoped to add some headers in addition. This method is used to solve it.

Please refer to the document of Egg::Plugin::MailSend::ISO2022JP.

HANDLER METHODS

The module for the handler Egg::Plugin::MailSend::CMD, Egg::Plugin::MailSend::SMTP, It drinks and 2 kinds are prepared.

Please refer to that document.

new

Constructor for handler.

reset ( [SETUP_HASH] )

The setting is initialized. SETUP_HASH overwrites the setting.

send ( [PARAM_HASH] )

Mail is transmitted, and the frequency that succeeds in the transmission is returned.

$e->mail->send(
  to => 'gooo@mail.address',
  .....
  ...
  );

body ( [MAIL_BODY] )

The content of mail can be registered beforehand.

Please give MAIL_BODY SCALAR or ARRAY.

to ( [TO_ADDR] )

The destination of mail can be registered beforehand.

Please give TO_ADDR SCALAR or ARRAY.

from ( [FROM_ADDR] )

The transmission origin of mail can be registered beforehand.

Please give FROM_ADDR with SCALAR.

cc ( [CC_ADDR] )

The Cc address can be registered beforehand.

Please give it by the character string of ',' delimitation when you specify two or more addresses.

bcc ( [BCC_ADDR] )

The Bcc address can be registered beforehand.

Please give it by the character string of ',' delimitation when you specify two or more addresses.

reply_to ( [REPLY_ADDR] )

The address can be registered beforehand the reply ahead.

return_path ( [RETURN_ADDR] )

It can register replying ahead of the error mail beforehand.

subject ( [SUBJECT_STRING] )

The subject of mail can be registered beforehand.

body_header ( [HEADER_TEXT] )

The header buried under the content of mail can be registered beforehand.

The footer buried under the content of mail can be registered beforehand.

SEE ALSO

MIME::Entity, Egg::Plugin::MailSend::CMD, Egg::Plugin::MailSend::SMTP, Egg::Plugin::MailSend::Encode::ISO2022JP, Egg::Base, Egg::Release,

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.