E-Mail-Acme

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


      push @$e_mail, $part_1, $part_2;

    Any lines in a multi-part e-mail message form the preamble, and an
    arrayref of subparts is always available at the end of the e-mail --
    that is, like this:

      my $subparts = $e_mail->[ scalar @$e_mail ];

    Nested multipart messages are handled just fine. A multipart
    content-type will be added, if none has been supplied. If a multipart
    content-type is set, but the boundary is not, it will be added. Do not
    set your own boundary unless you know what you are doing! You will
    probably produce a corrupt message!

SENDING MAIL
    A mail exists to be sent, not hoarded! Once you've composed your e-mail
    message, you can send it just how you'd expect:

      $e_mail->();

    If your sendmail program is not installed in your path, you can specify

lib/E/Mail/Acme.pm  view on Meta::CPAN

package E'Mail::Acme;

$E'Mail::Acme::VERSION = 1555;

my $CRLF = "\x0d\x0a";

use overload '""' => sub {
  my ($self) = @_;

  if (@{$self->[ @$self ]}) {
    unless (($self->{'content-type'}->[0]||'') =~ qr{^multipart/}) {
      warn "content-type set, but not multipart on multipart message"
        if $self->{'content-type'};
      delete $self->{'content-type'};
      $self->{'content-type'} = qq{multipart/mixed};
    }

    unless ($self->{'content-type'}->[0] =~ qr{boundary="(?:[^"]+)"}) {
      $self->{'content-type'}->[0] .= qq{; boundary="$self->[@$self+1]"};
    }
  }

  join(
    $CRLF,
    $self->{''},
    join($CRLF, @{ $_[0] }, '')
    . (
      @{ $_[0]->[ @{ $_[0] } ] }
      ? "$CRLF--$_[0]->[ @{ $_[0] } + 1 ]$CRLF"

lib/E/Mail/Acme.pm  view on Meta::CPAN

  my $part_1 = E'Mail::Acme; # attachment
  my $part_2 = E'Mail::Acme; # attachment

  push @$e_mail, $part_1, $part_2;

Any lines in a multi-part e-mail message form the preamble, and an arrayref of
subparts is always available at the end of the e-mail -- that is, like this:

  my $subparts = $e_mail->[ scalar @$e_mail ];

Nested multipart messages are handled just fine.  A multipart content-type will
be added, if none has been supplied.  If a multipart content-type is set, but
the boundary is not, it will be added.  Do not set your own boundary unless you
know what you are doing!  You will probably produce a corrupt message!

=head1 SENDING MAIL

A mail exists to be sent, not hoarded!  Once you've composed your e-mail
message, you can send it just how you'd expect:

  $e_mail->();

t/simple.t  view on Meta::CPAN

  );

  is($e_mail->[-1], "rjbs", "last line is correct");

  # print $e_mail "manager, e-mail enterprises";
  # is($e_mail->[-1], "manager, e-mail enterprises", "print to push");

  is_deeply($e_mail->[ @$e_mail ], [], "message is single-part");

  my $part = E'Mail::Acme;#'
  $part->{'content-type'} = "text/plain";
  push @$part, "This is plain text.";

  push @$e_mail, $part;

  is_deeply($e_mail->[ @$e_mail ], [ $part ], "message subparts are ok");
}

{
  $e_mail = E'Mail::Acme;#'



( run in 1.314 second using v1.01-cache-2.11-cpan-524268b4103 )