view release on metacpan or search on metacpan
$VERSION = '0.39';
use constant BUFFSIZE => 64;
my %h_hash = (
'content-type' => "",
'content-disposition' => "",
'content-transfer-encoding' => "",
);
my @patterns = (
}
next;
}
next if(!$checkhdr && (length() <= 2) && /$patterns[2]/o);
$header = 0;
if(exists($_[0]->{$tree}->{'content-type'}) && exists($_[0]->{$tree}->{'content-type'}->{value})) {
$_[0]->{$tree}->{'content-type'}->{value} = lc($_[0]->{$tree}->{'content-type'}->{value});
if(exists($_[0]->{$tree}->{'content-type'}->{boundary}) && $_[0]->{$tree}->{'content-type'}->{value} =~ /multipart\/\w+/o) {
my $res = &_parse($fhs, $header, $mbox, $tree, $_[0]->{$tree}->{'content-type'}->{boundary}, $args, $files, $_[0]);
if($res->[1]) {
$mbox ? ($tmp = 1) : return([$tree, $res->[1]]);
$_ = $res->[1];
} else { next; }
} elsif($_[0]->{$tree}->{'content-type'}->{value} eq "message/rfc822") {
my $res = &_parse($fhs, 1, $mbox, $tree, $origin, $args, $files, $_[0]);
if($res->[1]) {
$mbox ? ($tmp = 1) : return([$tree, $res->[1]]);
$_ = $res->[1];
} else { next; }
{
action => $args->{'types_action'},
mimetypes => $args->{'ctypes'}
}
);
$_[0]->{"$tree.$attcount"}->{'content-type'}->{value} = $res->[0];
$_[0]->{"$tree.$attcount"}->{'content-disposition'}->{filepath} = $filepath unless($res->[1]);
$attcount++;
next;
}
my $breakmsg = "";
unless(defined($fh)) {
$boundary = $origin;
if(exists($_[0]->{$tree}->{'content-type'}) && exists($_[0]->{$tree}->{'content-type'}->{value})) {
$exclude = 1 if(($_[0]->{$tree}->{'content-type'}->{value} =~ /^multipart\/\w+$/o) || ($_[0]->{$tree}->{'content-type'}->{value} eq "message/rfc822"));
} else { $check_ctype = 1; }
unless($exclude) {
if(exists($_[0]->{$tree}->{'content-transfer-encoding'}) &&
exists($_[0]->{$tree}->{'content-transfer-encoding'}->{value})) {
$_[0]->{$tree}->{'content-transfer-encoding'}->{value} = lc($_[0]->{$tree}->{'content-transfer-encoding'}->{value});
my $res = &decode_content($fhs,
$_[0]->{$tree}->{'content-transfer-encoding'}->{value},
$filepath,
$boundary ? "--$boundary" : "",
{
mimetype => $_[0]->{$tree}->{'content-type'}->{value} || "",
checktype => $args->{'check_ctype'},
action => $args->{'types_action'},
mimetypes => $args->{'ctypes'},
mailbox => $mbox
});
$_[0]->{$tree}->{'content-type'}->{value} = $res->[1] if($res->[1]);
$_[0]->{$tree}->{'content-disposition'}->{filepath} = $filepath unless($res->[2]);
$tmp = 1;
unless($_ = $res->[0]) {
$exclude = 1;
next;
if(index($_, "--$boundary") >= 0) {
defined($fh) and &file_close($fh);
($tmp, $header) = (1, 1);
$boundary = "";
if($ph) {
return([$tree]) if($_[0]->{$base}->{'content-type'}->{value} eq "message/rfc822");
my @ps = split(/\./o, $tree);
$ps[$#ps]++;
$tree = join("\.", @ps);
}
next;
}
(!$exclude && $ph) or next;
if($check_ctype && $args->{check_ctype}) {
($tmpbuff .= $_) =~ s/^[\n\r\t]+//o;
if(length($tmpbuff) > BUFFSIZE) {
$_[0]->{$tree}->{'content-type'}->{value} ||= "";
if(my $ct = set_content_type($tmpbuff, $_[0]->{$tree}->{'content-type'}->{value})) {
$_[0]->{$tree}->{'content-type'}->{value} = $ct;
$tmpbuff = "";
$check_ctype = 0;
}
if($exclude = exists($args->{'ctypes'}->{$_[0]->{$tree}->{'content-type'}->{value}}) ? ($args->{'types_action'} ? 0 : 1) :
scalar(keys(%{$args->{'ctypes'}})) ? ($args->{'types_action'} ? 1 : 0) : ($args->{'types_action'} ? 0 : 1)) {
if(defined($fh)) {
&file_close($fh);
unlink($_[0]->{$tree}->{'content-disposition'}->{filepath});
delete($_[0]->{$tree}->{'content-disposition'}->{filepath});
my $h = shift;
my $file = "file";
if(exists($h->{'content-disposition'}->{filename})) {
$file = $h->{'content-disposition'}->{filename};
} elsif(exists($h->{'content-type'}->{name})) {
$file = $h->{'content-type'}->{name};
} elsif(exists($h->{'content-type'}->{value})) {
my $ctype = lc($h->{'content-type'}->{value});
$file .= $content_type{$ctype} || "";
}
$file =~ s/^[ \.]+$/file/o;
$h->{'content-disposition'}->{filename} = &check_filename($files, $file);
$h->{'content-transfer-encoding'}->{value} = "" unless(exists($h->{'content-transfer-encoding'}->{value}));
If the value is set to octal number then make the output_dir directory
(example: mkdir => 0755).
=item check_content_type => 0 or 1
If the value is set to 1 the content-type of file is checked
=item decode_subject => 0 or 1
If the value is set to 1 then the subject is decoded into a list.
view all matches for this distribution
view release on metacpan or search on metacpan
=item I<new> ()
=item I<new> (subtype = "mixed")
Class method.
Creates a new MIME::Fast::MultiPart object with a default content-type of
multipart/mixed.
=item I<set_preface> (text)
=item I<get_preface> ()
=item I<set_content_type_parameter> ($name, $value)
=item I<get_content_type_parameter> ($name)
Sets or gets the value of the content-type param $name set on the MIME part object.
=item I<set_content_id> (content_id)
=item I<get_content_id> ()
=over 4
=item I<new> (subtype = "rfc822" [, message])
Creates a new MIME message part object with a default content-type
of message/$subtype (optionally containing $message object).
=item I<set_message> (message)
=item I<get_message> ()
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MIME/Lite/Generator.pm view on Meta::CPAN
my $sub_attrs = $self->{msg}{SubAttrs};
my $rv;
$self->{state} = 'first';
### Output either the body or the parts.
### Notice that we key off of the content-type! We expect fewer
### accidents that way, since the syntax will always match the MIME type.
my $type = $attrs->{'content-type'};
if ( $type =~ m{^multipart/}i ) {
$self->{boundary} = $sub_attrs->{'content-type'}{'boundary'};
### Preamble:
$rv = \($self->{msg}->header_as_string . "\n" . (
defined( $self->{msg}{Preamble} )
? $self->{msg}{Preamble}
view all matches for this distribution
view release on metacpan or search on metacpan
my $ref = ($txt || @$ref_mail) ? {} : $self->{_param};
$part = new MIME::Lite(%$ref,
'Type' => 'TEXT',
'Encoding' => $self->{_htmlencoding},
'Data' => $html);
$part->attr("content-type"=> "text/html; charset=".$self->{_htmlcharset});
# Remove some header for Eudora client in HTML and related part
$part->replace("MIME-Version" => "");
$part->replace('X-Mailer' =>"");
$part->replace('Content-Disposition' =>"");
# only html, no images & no txt
my $ref = ($html ? {} : $self->{_param} );
$txt_part = new MIME::Lite (%$ref,
'Type' => 'TEXT',
'Data' => $txt,
'Encoding' => $self->{_textencoding});
$txt_part->attr("content-type" =>
"text/plain; charset=".$self->{_textcharset});
# Remove some header for Eudora client
$txt_part->replace("MIME-Version" => "");
$txt_part->replace("X-Mailer" => "");
$txt_part->replace("Content-Disposition" => "");
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MIME/Lite.pm view on Meta::CPAN
#pod $part = MIME::Lite->new(
#pod Top => 0,
#pod Type =>'text/html',
#pod Data =>'<H1>Hello</H1>',
#pod );
#pod $part->attr('content-type.charset' => 'UTF-8');
#pod $part->add('X-Comment' => 'A message for you');
#pod
#pod ### Attach it to any message:
#pod $msg->attach($part);
#pod
lib/MIME/Lite.pm view on Meta::CPAN
#pod method assumes that you are giving in the pairs of a PARAMHASH
#pod which will be sent into C<new()> to create the new part.
#pod
#pod One of the possibly-quite-useful hacks thrown into this is the
#pod "attach-to-singlepart" hack: if you attempt to attach a part (let's
#pod call it "part 1") to a message that doesn't have a content-type
#pod of "multipart" or "message", the following happens:
#pod
#pod =over 4
#pod
#pod =item *
lib/MIME/Lite.pm view on Meta::CPAN
### Create new part, if necessary:
my $part1 = ( ( @_ == 1 ) ? shift: ref($self)->new( Top => 0, @_ ) );
### Do the "attach-to-singlepart" hack:
if ( $attrs->{'content-type'} !~ m{^(multipart|message)/}i ) {
### Create part zero:
my $part0 = ref($self)->new;
### Cut MIME stuff from self, and paste into part zero:
lib/MIME/Lite.pm view on Meta::CPAN
$part0->top_level(0); ### clear top-level attributes
### Make self a top-level multipart:
$attrs = $self->{Attrs} ||= {}; ### reset (sam: bug? this doesn't reset anything since Attrs is already a hash-ref)
$sub_attrs = $self->{SubAttrs} ||= {}; ### reset
$attrs->{'content-type'} = 'multipart/mixed';
$sub_attrs->{'content-type'}{'boundary'} = gen_boundary();
$attrs->{'content-transfer-encoding'} = '7bit';
$self->top_level(1); ### activate top-level attributes
### Add part 0:
push @{ $self->{Parts} }, $part0;
lib/MIME/Lite.pm view on Meta::CPAN
### CONTENT-TYPE....
###
### Get content-type or content-type-macro:
my $type = ( $params{Type} || ( $AUTO_CONTENT_TYPE ? 'AUTO' : 'TEXT' ) );
### Interpret content-type-macros:
if ( $type eq 'TEXT' ) { $type = 'text/plain'; }
elsif ( $type eq 'HTML' ) { $type = 'text/html'; }
elsif ( $type eq 'BINARY' ) { $type = 'application/octet-stream' }
elsif ( $type eq 'AUTO' ) { $type = $self->suggest_type( $params{Path} ); }
### We now have a content-type; set it:
$type = lc($type);
my $attrs = $self->{Attrs};
my $sub_attrs = $self->{SubAttrs};
$attrs->{'content-type'} = $type;
### Get some basic attributes from the content type:
my $is_multipart = ( $type =~ m{^(multipart)/}i );
### Add in the multipart boundary:
if ($is_multipart) {
my $boundary = gen_boundary();
$sub_attrs->{'content-type'}{'boundary'} = $boundary;
}
### CONTENT-ID...
###
lib/MIME/Lite.pm view on Meta::CPAN
#pod I<Instance method.>
#pod Set MIME attribute ATTR to the string VALUE.
#pod ATTR is converted to all-lowercase.
#pod This method is normally used to set/get MIME attributes:
#pod
#pod $msg->attr("content-type" => "text/html");
#pod $msg->attr("content-type.charset" => "US-ASCII");
#pod $msg->attr("content-type.name" => "homepage.html");
#pod
#pod This would cause the final output to look something like this:
#pod
#pod Content-type: text/html; charset=US-ASCII; name="homepage.html"
#pod
lib/MIME/Lite.pm view on Meta::CPAN
#pod Giving VALUE as undefined will cause the contents of the named
#pod subfield to be deleted.
#pod
#pod Supplying no VALUE argument just returns the attribute's value:
#pod
#pod $type = $msg->attr("content-type"); ### returns "text/html"
#pod $name = $msg->attr("content-type.name"); ### returns "homepage.html"
#pod
#pod =cut
sub attr {
lib/MIME/Lite.pm view on Meta::CPAN
#pod =item field_order FIELD,...FIELD
#pod
#pod I<Class/instance method.>
#pod Change the order in which header fields are output for this object:
#pod
#pod $msg->field_order('from', 'to', 'content-type', 'subject');
#pod
#pod When used as a class method, changes the default settings for
#pod all objects:
#pod
#pod MIME::Lite->field_order('from', 'to', 'content-type', 'subject');
#pod
#pod Case does not matter: all field names will be coerced to lowercase.
#pod In either case, supply the empty array to restore the default ordering.
#pod
#pod =cut
lib/MIME/Lite.pm view on Meta::CPAN
sub filename {
my ( $self, $filename ) = @_;
my $sub_attrs = $self->{SubAttrs};
if ( @_ > 1 ) {
$sub_attrs->{'content-type'}{'name'} = $filename;
$sub_attrs->{'content-disposition'}{'filename'} = $filename;
}
return $sub_attrs->{'content-disposition'}{'filename'};
}
lib/MIME/Lite.pm view on Meta::CPAN
# and given the performance cost of calculating it from a file handle,
# I thought it might make more sense to add some sort of computelength
# property. If computelength is false, then the length simply isn't
# computed. What do you think?
#
# Eryq's reply: I agree; for now, we can silently leave out the content-type.
sub get_length {
my $self = shift;
my $attrs = $self->{Attrs};
my $is_multipart = ( $attrs->{'content-type'} =~ m{^multipart/}i );
my $enc = lc( $attrs->{'content-transfer-encoding'} || 'binary' );
my $length;
if ( !$is_multipart && ( $enc eq "binary" ) ) { ### might figure it out cheap:
if ( defined( $self->{Data} ) ) { ### it's in core
$length = length( $self->{Data} );
lib/MIME/Lite.pm view on Meta::CPAN
if ( !@a ) { ### guess
### Scrub length always:
$self->replace( 'content-length', '' );
### Scrub disposition if no filename, or if content-type has same info:
if ( !$self->_safe_attr('content-disposition.filename')
|| $self->_safe_attr('content-type.name') )
{
$self->replace( 'content-disposition', '' );
}
### Scrub encoding if effectively unencoded:
if ( $self->_safe_attr('content-transfer-encoding') =~ /^(7bit|8bit|binary)$/i ) {
$self->replace( 'content-transfer-encoding', '' );
}
### Scrub charset if US-ASCII:
if ( $self->_safe_attr('content-type.charset') =~ /^(us-ascii)/i ) {
$self->attr( 'content-type.charset' => undef );
}
### TBD: this is not really right for message/digest:
if ( ( keys %{ $self->{Attrs}{'content-type'} } == 1 )
and ( $self->_safe_attr('content-type') eq 'text/plain' ) )
{
$self->replace( 'content-type', '' );
}
} elsif ( $expl and ( ref($expl) eq 'ARRAY' ) ) {
foreach ( @{$expl} ) { $self->replace( $_, '' ); }
}
lib/MIME/Lite.pm view on Meta::CPAN
sub binmode {
my $self = shift;
$self->{Binmode} = shift if (@_); ### argument? set override
return ( defined( $self->{Binmode} )
? $self->{Binmode}
: ( $self->{Attrs}{"content-type"} !~ m{^(text|message)/}i )
);
}
#------------------------------
lib/MIME/Lite.pm view on Meta::CPAN
#------------------------------
#
# =item suggest_type PATH
#
# I<Class/instance method.>
# Suggest the content-type for this attached path.
# We always fall back to "application/octet-stream" if no good guess
# can be made, so don't use this if you don't mean it!
#
sub suggest_type {
my ( $self, $path ) = @_;
lib/MIME/Lite.pm view on Meta::CPAN
### Coerce into a printable output handle:
$out = MIME::Lite::IO_Handle->wrap($out);
### Output either the body or the parts.
### Notice that we key off of the content-type! We expect fewer
### accidents that way, since the syntax will always match the MIME type.
my $type = $attrs->{'content-type'};
if ( $type =~ m{^multipart/}i ) {
my $boundary = $sub_attrs->{'content-type'}{'boundary'};
### Preamble:
$out->print( defined( $self->{Preamble} )
? $self->{Preamble}
: "This is a multi-part message in MIME format.\n"
lib/MIME/Lite.pm view on Meta::CPAN
$part = MIME::Lite->new(
Top => 0,
Type =>'text/html',
Data =>'<H1>Hello</H1>',
);
$part->attr('content-type.charset' => 'UTF-8');
$part->add('X-Comment' => 'A message for you');
### Attach it to any message:
$msg->attach($part);
lib/MIME/Lite.pm view on Meta::CPAN
method assumes that you are giving in the pairs of a PARAMHASH
which will be sent into C<new()> to create the new part.
One of the possibly-quite-useful hacks thrown into this is the
"attach-to-singlepart" hack: if you attempt to attach a part (let's
call it "part 1") to a message that doesn't have a content-type
of "multipart" or "message", the following happens:
=over 4
=item *
lib/MIME/Lite.pm view on Meta::CPAN
I<Instance method.>
Set MIME attribute ATTR to the string VALUE.
ATTR is converted to all-lowercase.
This method is normally used to set/get MIME attributes:
$msg->attr("content-type" => "text/html");
$msg->attr("content-type.charset" => "US-ASCII");
$msg->attr("content-type.name" => "homepage.html");
This would cause the final output to look something like this:
Content-type: text/html; charset=US-ASCII; name="homepage.html"
lib/MIME/Lite.pm view on Meta::CPAN
Giving VALUE as undefined will cause the contents of the named
subfield to be deleted.
Supplying no VALUE argument just returns the attribute's value:
$type = $msg->attr("content-type"); ### returns "text/html"
$name = $msg->attr("content-type.name"); ### returns "homepage.html"
=item delete TAG
I<Instance method.>
Delete field TAG with the given VALUE to the end of the header.
lib/MIME/Lite.pm view on Meta::CPAN
=item field_order FIELD,...FIELD
I<Class/instance method.>
Change the order in which header fields are output for this object:
$msg->field_order('from', 'to', 'content-type', 'subject');
When used as a class method, changes the default settings for
all objects:
MIME::Lite->field_order('from', 'to', 'content-type', 'subject');
Case does not matter: all field names will be coerced to lowercase.
In either case, supply the empty array to restore the default ordering.
=item fields
lib/MIME/Lite.pm view on Meta::CPAN
=over 4
=item Content-type
You can safely scrub the "content-type" attribute if, and only if,
the part is of type "text/plain" with charset "us-ascii".
=item Content-transfer-encoding
You can safely scrub the "content-transfer-encoding" attribute
lib/MIME/Lite.pm view on Meta::CPAN
=item Content-disposition
You can safely scrub the "content-disposition" attribute
if you trust the mail reader to do the right thing when it decides
whether to show an attachment inline or as a link. Be aware
that scrubbing both the content-disposition and the content-type
means that there is no way to "recommend" a filename for the attachment!
B<Note:> there are reports of brain-dead MUAs out there that
do the wrong thing if you I<provide> the content-disposition.
If your attachments keep showing up inline or vice-versa,
lib/MIME/Lite.pm view on Meta::CPAN
From => 'me@myhost.com',
To => encode( 'MIME-Header', $to ),
Subject => encode( 'MIME-Header', $subject ),
Data => encode_utf8($text)
);
$msg->attr( 'content-type' => 'text/plain; charset=utf-8' );
$msg->send;
B<Note:>
=over
lib/MIME/Lite.pm view on Meta::CPAN
=item *
If, for the body of the email, you want to use a character set
other than UTF-8, then you should encode appropriately, and set the
correct C<content-type>, eg:
...
Data => encode('iso-8859-15',$text)
...
$msg->attr( 'content-type' => 'text/plain; charset=iso-8859-15' );
=item *
For the message headers, L<Encode::MIME::Header> only support UTF-8,
but most modern mail clients should be able to handle this. It is not
lib/MIME/Lite.pm view on Meta::CPAN
#pod
#pod =over 4
#pod
#pod =item Content-type
#pod
#pod You can safely scrub the "content-type" attribute if, and only if,
#pod the part is of type "text/plain" with charset "us-ascii".
#pod
#pod =item Content-transfer-encoding
#pod
#pod You can safely scrub the "content-transfer-encoding" attribute
lib/MIME/Lite.pm view on Meta::CPAN
#pod =item Content-disposition
#pod
#pod You can safely scrub the "content-disposition" attribute
#pod if you trust the mail reader to do the right thing when it decides
#pod whether to show an attachment inline or as a link. Be aware
#pod that scrubbing both the content-disposition and the content-type
#pod means that there is no way to "recommend" a filename for the attachment!
#pod
#pod B<Note:> there are reports of brain-dead MUAs out there that
#pod do the wrong thing if you I<provide> the content-disposition.
#pod If your attachments keep showing up inline or vice-versa,
lib/MIME/Lite.pm view on Meta::CPAN
#pod From => 'me@myhost.com',
#pod To => encode( 'MIME-Header', $to ),
#pod Subject => encode( 'MIME-Header', $subject ),
#pod Data => encode_utf8($text)
#pod );
#pod $msg->attr( 'content-type' => 'text/plain; charset=utf-8' );
#pod $msg->send;
#pod
#pod B<Note:>
#pod
#pod =over
lib/MIME/Lite.pm view on Meta::CPAN
#pod
#pod =item *
#pod
#pod If, for the body of the email, you want to use a character set
#pod other than UTF-8, then you should encode appropriately, and set the
#pod correct C<content-type>, eg:
#pod
#pod ...
#pod Data => encode('iso-8859-15',$text)
#pod ...
#pod
#pod $msg->attr( 'content-type' => 'text/plain; charset=iso-8859-15' );
#pod
#pod =item *
#pod
#pod For the message headers, L<Encode::MIME::Header> only support UTF-8,
#pod but most modern mail clients should be able to handle this. It is not
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MIME/Mini.pm view on Meta::CPAN
sub formail # rfc2822 + mboxrd format (see http://www.qmail.org/man/man5/mbox.html)
{
sub mime # rfc2045, rfc2046
{
my ($mail, $parent) = @_;
return $mail unless exists $mail->{header} && exists $mail->{header}->{'content-type'} || defined $parent && exists $parent->{mime_type} && $parent->{mime_type} =~ /^multipart\/digest$/i;
my ($content_type) = (exists $mail->{header} && exists $mail->{header}->{'content-type'}) ? @{$mail->{header}->{'content-type'}} : "Content-Type: message/rfc822\n";
my ($type) = $content_type =~ /^content-type:\s*([\w\/.-]+)/i;
my $boundary = param($mail, 'content-type', 'boundary') if $type =~ /^multipart\//i;
return $mail unless defined $type && ($type =~ /^multipart\//i && $boundary || $type =~ /^message\/rfc822$/i);
($mail->{mime_boundary}) = $boundary =~ /^(.*\S)/ if $boundary;
$mail->{mime_type} = $type;
$mail->{mime_message} = mimepart(delete $mail->{body} || '', $mail), return $mail if $type =~ /^message\/(?:rfc822|external-body)$/i;
return tnef2mime(mimeparts($mail, $parent));
lib/MIME/Mini.pm view on Meta::CPAN
sub mimetype # rfc2045, rfc2046
{
my ($m, $p) = @_;
my ($e) = header($m, 'content-transfer-encoding');
return 'application/octet-stream' if defined $e && $e !~ /^(?:[78]bit|binary|quoted-printable|base64)$/i;
my ($type) = header($m, 'content-type');
return lc $1 if defined $type && $type =~ /^((?:text|image|audio|video|application|message|multipart)\/[^\s;]+)/i;
return 'message/rfc822' if !defined $type && defined $p && exists $p->{mime_type} && $p->{mime_type} =~ /^multipart\/digest/i;
return 'text/plain';
}
lib/MIME/Mini.pm view on Meta::CPAN
my $filename_counter;
sub filename # rfc2183, rfc2045?
{
my $p = shift;
my $fn = param($p, 'content-disposition', 'filename') || param($p, 'content-type', 'name') || 'attachment' . ++$filename_counter;
$fn =~ s/^.*[\\\/]//, $fn =~ tr/\x00-\x1f !"#\$%&'()*\/:;<=>?@[\\]^`{|}~\x7f/_/s;
return $fn;
}
sub body
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MIME/Signature.pm view on Meta::CPAN
our %EXPORT_TAGS = ();
sub _decoded_body {
my $entity = shift;
my $body = $entity->bodyhandle->as_string;
if ( my $charset = $entity->head->mime_attr('content-type.charset') ) {
$body = decode $charset, $body;
}
$body;
}
lib/MIME/Signature.pm view on Meta::CPAN
my ( $entity, $body ) = @_;
$body .= "\n" if $body !~ /\n\z/;
my $encoded_body;
{
my $encoding_ok;
if ( my $charset = $entity->head->mime_attr('content-type.charset') ) {
$encoding_ok = 1;
$encoded_body = encode $charset, $body,
sub { undef $encoding_ok; '' };
}
unless ($encoding_ok) {
my $head = $entity->head;
$head->mime_attr( 'Content-Type', 'text/plain' )
unless $head->mime_attr('content-type');
$head->mime_attr( 'content-type.charset' => 'UTF-8' );
$encoded_body = encode_utf8($body);
}
}
my $fh = $entity->bodyhandle->open('w') or die "Open body: $!\n";
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MIME/Structure.pm view on Meta::CPAN
my $level = $entity->{'level'} = @context - 1;
if (@context > 1) {
# Current entity is $context[-1]
$parent = $entity->{'parent'} = $context[-2];
}
my ($content_type) = @{ $fields->{'content-type'} || [] };
if (!defined $content_type) {
if ($parent && "$parent->{'type'}/$parent->{'subtype'}" eq 'multipart/digest') {
$content_type = 'message/rfc822'
}
else {
lib/MIME/Structure.pm view on Meta::CPAN
Returns a string showing the structure of a message, including the content
type and offset of each entity (i.e., the message and [if it's multipart] all
of its parts, recursively). Each entity is printed in the form:
"(" content-type ":" byte-offset [ " " parts... ")"
Offsets are B<byte> offsets of the entity's header from the beginning of the
message. (If B<parse()> was called with an I<offset> parameter, this is added
to the offset of the entity's header.)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MIME/Entity.pm view on Meta::CPAN
Encoding =>"quoted-printable",
From =>'jean.luc@inria.fr',
Subject =>"C'est bon!");
Create a document for a GIF file (the description is completely optional;
note that we have to specify content-type and encoding since they're
not the default values):
$ent = MIME::Entity->build(Description => "A pretty picture",
Path => "./docs/mime-sm.gif",
Type => "image/gif",
lib/MIME/Entity.pm view on Meta::CPAN
array, etc.) If OFFSET is not given, the new part is added to the end
of the array.
I<Thanks to Jason L Tibbitts III for providing support for OFFSET.>
B<Warning:> in general, you only want to attach parts to entities
with a content-type of C<multipart/*>).
=cut
sub add_part {
my ($self, $part, $index) = @_;
lib/MIME/Entity.pm view on Meta::CPAN
=item Filename
I<Single-part entities only. Optional.>
The recommended filename. Overrides any name extracted from C<Path>.
The information is stored both the deprecated (content-type) and
preferred (content-disposition) locations. If you explicitly want to
I<avoid> a recommended filename (even when Path is used), supply this
as empty or undef.
=item Id
lib/MIME/Entity.pm view on Meta::CPAN
The default is true. (NB: look at how C<attach()> uses it.)
=item Type
I<Optional.>
The basic content-type (C<"text/plain">, etc.).
If you don't specify it, it defaults to C<"text/plain">
as per RFC 2045. I<Do yourself a favor: put it in.>
=back
lib/MIME/Entity.pm view on Meta::CPAN
### Create head:
my $head = new MIME::Head;
$self->head($head);
$head->modify(1);
### Add content-type field:
$field = new Mail::Field 'Content_type'; ### not a typo :-(
$field->type($type);
$field->charset($charset) if $charset;
$field->name($filename) if defined($filename);
$field->boundary($boundary) if defined($boundary);
$head->replace('Content-type', $field->stringify);
### Now that both body and content-type are available, we can suggest
### content-transfer-encoding (if desired);
if (!$encoding) {
$encoding = $self->suggest_encoding_lite;
}
elsif (lc($encoding) eq '-suggest') {
lib/MIME/Entity.pm view on Meta::CPAN
like C<smtpsend()> will work. Note however that if VALUE is given,
a fatal exception is thrown, since you cannot use this method to
I<set> the lines of the encoded message.
If you want the raw (unencoded) body data, use the L<bodyhandle()|/bodyhandle>
method to get and use a MIME::Body. The content-type of the entity
will tell you whether that body is best read as text (via getline())
or raw data (via read()).
=cut
lib/MIME/Entity.pm view on Meta::CPAN
C<NLINES> of the message. If found then that line and all lines after
it will be removed. If C<NLINES> is not given, a default value of 10
will be used. This would be of most use in auto-reply scripts.
For MIME entity, this method is reasonably cautious: it will only
attempt to un-sign a message with a content-type of C<text/*>.
If you send remove_sig() to a multipart entity, it will relay it to
the first part (the others usually being the "attachments").
B<Warning:> currently slurps the whole message-part into core as an
lib/MIME/Entity.pm view on Meta::CPAN
Fatal error if it can't be read.
I<As per superclass method.>
=item Force
Sign it even if the content-type isn't C<text/*>. Useful for
non-standard types like C<x-foobar>, but be careful!
I<MIME-specific; new in this subclass.>
=item Remove
lib/MIME/Entity.pm view on Meta::CPAN
I<As per superclass method.>
=back
For MIME messages, this method is reasonably cautious: it will only
attempt to sign a message with a content-type of C<text/*>, unless
C<Force> is specified.
If you send this message to a multipart entity, it will relay it to
the first part (the others usually being the "attachments").
lib/MIME/Entity.pm view on Meta::CPAN
video/*
=item *
An array of I<parts>, where each part is a MIME::Entity object.
The number of parts will only be nonzero if the content-type
is I<not> one of the "singlepart" types:
message/* (should have exactly one part)
multipart/* (should have one or more parts)
lib/MIME/Entity.pm view on Meta::CPAN
B<Mail::Internet:>
As an array of lines.
B<MIME::Entity:>
It depends on the content-type of the message.
For "container" types (C<multipart/*>, C<message/*>), we store the
contained entities as an array of "parts", accessed via the C<parts()>
method, where each part is a complete MIME::Entity.
For "singlepart" types (C<text/*>, C<image/*>, etc.), the unencoded
body data is referenced via a MIME::Body object, accessed via
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MKDoc/Apache_Cache.pm view on Meta::CPAN
$headers ||= '';
$body ||= '';
my @o = ();
# Figure out some kind of content_type
my ($content_type) = grep /^content-type\:/i, split (/\r?\n/, $headers);
$content_type ||= 'application/octet-stream';
# Gzip body if content type probably needs gzipping
# Vary: Accept-Encoding is here to tell proxies to keep a separate
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MKDoc/Core/Plugin.pm view on Meta::CPAN
=head2 $self->HTTP_Content_Type();
Returns the content-type associated with this plugin.
By default, returns "text/html; charset=UTF-8"
=cut
sub HTTP_Content_Type { "text/html; charset=UTF-8" }
view all matches for this distribution
view release on metacpan or search on metacpan
eg/cgi_search.pl view on Meta::CPAN
#$Id: cgi_search.pl,v 1.5 1999/04/26 12:14:31 maxim Exp $
# Quick and dirty cgi-script to search a website.
# (Root dir must have been indexed using html_indexer.pl)
my $dbname = '.search.db';
BEGIN { print "content-type: text/html\n\n"; }
my $query_string = $ENV{QUERY_STRING};
if ( $query_string !~ /\S/ ) {
print_search_page();
view all matches for this distribution
view release on metacpan or search on metacpan
t/03.PDU-common-fields.t
t/04.basic-rules.t
t/05.length.t
t/06.parameter-values.t
t/07.parameter.t
t/08.content-type.t
t/09.multipart.t
t/20.immediates.t
t/21.straight.t
t/pod-coverage.t
t/pod.t
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MP3/M3U/Parser/Export.pm view on Meta::CPAN
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>MP3::M3U::Parser Generated PlayList</title>
<meta name="Generator" content="MP3::M3U::Parser">
<meta http-equiv="content-type"
content="text/html; charset=<%$HTML{ENCODING}%>">
<style type="text/css">
<!--
body { background : #000040;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MPMinus/REST.pm view on Meta::CPAN
my $meth = uc($r->method() || 'GET');
my $is_get = $meth =~ /GET|HEAD/ ? 1 : 0;
my $headers = $r->headers_in(); # APR::Table object
# If content-type is predefined! Nothing to do
my $content_type = $self->get_attr("content_type");
if ($content_type) {
$self->set_svar(format => _ctlookup($content_type) || FORMAT);
$r->content_type($content_type);
return Apache2::Const::OK;
}
# Content-Type Values from headers
my $req_content_type = $headers->get("content-type") // '';
my $req_accept = $headers->get("accept") // '';
# Try get format from request header first and from the Accept header
my $format = _ctlookup($req_content_type) || _ctlookup($req_accept);
my $default_format = $format || FORMAT;
view all matches for this distribution
view release on metacpan or search on metacpan
Changes.html view on Meta::CPAN
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Changes.src</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:perlcore@ms.com" />
</head>
<body style="background-color: white">
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MT/Import/Mbox.pm view on Meta::CPAN
event that no attachments are found it returns the body of the orginal message
as a 'part', or attachment.
If only one attachment exists it is used to generate the body of the entry.
If the first attachment content-type is determined to be either plain-text
or HTML it is used to generate the body of the entry.
All other attachments are written to disk. Attachments are written to disk as :
/your/static/weblog/attachments/$YYYY/$MM/$DD/$MSG_ID/$FNAME
lib/MT/Import/Mbox.pm view on Meta::CPAN
$MSG_ID is an MD5 digest of a normalized form of the message's Message-ID
header.
$FNAME is an MD5 digest of the attachment's body. If it is possible to
determine the attachment's content-type then a suitable extension is
appended to $FNAME.
A messsage's headers are stored as a separate attachment in :
/your/static/weblog/attachments/$YYYY/$MM/$DD/$MSG_ID/headers.txt
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MVC/Neaf.pm view on Meta::CPAN
The B<Model> is assumed to be just a regular Perl module,
no restrictions are imposed on it.
The B<View> is an object with one method, C<render>, receiving a hashref
and returning rendered content as string plus optional content-type header.
The B<Controller> is a prefix tree of subroutines called I<handlers>.
Each such handler receives a L<MVC::Neaf::Request> object
containing I<all> it needs to know about the outside world,
and returns a simple C<\%hashref> which is forwarded to View.
lib/MVC/Neaf.pm view on Meta::CPAN
=item * C<view> - default View object for this Controller.
Must be a name of preloaded view,
an object with a C<render> method, or a CODEREF
receiving hashref and returning a list of two scalars
(content and content-type).
B<[DEPRECATED]> Use C<-view> instead, meaning is exactly the same.
=item * C<cache_ttl> - if set, set Expires: HTTP header accordingly.
lib/MVC/Neaf.pm view on Meta::CPAN
will have non-absolute paths calculated relative to the file where
static() was called, not to the current directory.
=item * if coderef is given, use it as a C<render> method.
The coderef must take 1 argument - the hash returned from application -
and return a string + optional content-type.
=back
Returns the view object, NOT the calling Neaf object.
lib/MVC/Neaf.pm view on Meta::CPAN
=item * header = \%hash - override some headers
This gets overridden by type, cookie etc. in case of conflict
=item * body = 'DATA' - force body in request
=item * type - content-type of body
=item * uploads - a hash of L<MVC::Neaf::Upload> objects.
=item * secure = 0|1 - C<http> vs C<https>
view all matches for this distribution
view release on metacpan or search on metacpan
Bulkmail.pm view on Meta::CPAN
But it was just too hard for most people. So I added this flag.
Here's the order:
Check and see if ->header("Content-type") is set, if so then send it.
Otherwise, check and see if ->HTML is true, if so, then send a content-type of text/html
i.e., an HTML message
Otherwise, send a content-type of text/plain
i.e., a plaintext message
$bulk->HTML(1);
print $bulk->HTML();
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Mail/DKIM/Iterator.pm view on Meta::CPAN
use warnings;
use Crypt::OpenSSL::RSA;
use Scalar::Util 'dualvar';
# critical header fields which should be well protected
my @critical_headers = qw(from subject content-type content-transfer-encoding);
my $critical_headers_rx = do {
my $rx = join("|",@critical_headers);
qr{$rx}i;
};
# all header fields which should be included in the signature
lib/Mail/DKIM/Iterator.pm view on Meta::CPAN
C<Mail::DKIM::Iterator> will warn if it detects insufficent protection inside
the DKIM signature, i.e. if critical headers are not signed or if the body has
non-white-space data not covered by the body hash. Check the C<warning> function
on the result to get these warnings.
As critical are considered from, subject, content-type and
content-transfer-encoding since changes to these can significantly change the
interpretation of the mail by the MUA or user.
When signing C<Mail::DKIM::Iterator> will also protect all critical headers
against modification and adding extra fields as described in RFC 6376 section
view all matches for this distribution
view release on metacpan or search on metacpan
t/corpus/dk_headers_1.txt view on Meta::CPAN
for <test@dktest.jason.long.name>; Tue, 10 Oct 2006 15:27:14 -0400 (EDT)
Received: by ug-out-1314.google.com with SMTP id 29so952130ugc
for <test@dktest.jason.long.name>; Tue, 10 Oct 2006 12:27:13 -0700 (PDT)
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;
s=beta; d=gmail.com;
h=received:message-id:date:from:to:subject:mime-version:content-type;
b=JOYJLw6miPAjUXx+gIQm3NsWuFInq05TuJppyoxqTopYPe3bSKzRBPLw5X+OMO36re/FDEfZnOjJ4cNYvVPuld6JEikNjk2RK98unQvcdkgBPZODuE7g/vXgLZo005nQkwvfd+4dbpHiINsOTT/0ASxQ+65OcgBu0CRR/DO7z/M=
Received: by 10.66.240.12 with SMTP id n12mr8614290ugh;
Tue, 10 Oct 2006 12:27:12 -0700 (PDT)
Received: by 10.67.96.17 with HTTP; Tue, 10 Oct 2006 12:27:12 -0700 (PDT)
Date: Tue, 10 Oct 2006 15:27:12 -0400
view all matches for this distribution
view release on metacpan or search on metacpan
bin/dmarc_receive view on Meta::CPAN
* the message is marked as read/seen
* move message to [imap][a_done] folder (if defined)
=head3 IMAP Forensic report
IMAP forensic reports are detected by the presence of the content-types message/feedback-report and text/rfc822-headers. When a forensic report is detected it is moved to the [imap][f_done] IMAP folder.
=head2 File as message
Accepts the filename of a file containing a mail message. The message is parsed and stored.
view all matches for this distribution
view release on metacpan or search on metacpan
examples/mbox view on Meta::CPAN
X-Gnus-Article-Number: 17837 Tue, 02 Sep 2008 15:17:24 +0200
<html>
<head>
<meta http-equiv=3D"content-type" content=3D"text/html;charset=3Diso-88=
59-1">
<meta name=3D"generator" content=3D"Adobe GoLive">
<title>Page sans titre</title>
</head>
view all matches for this distribution
view release on metacpan or search on metacpan
# evil hack to compensate for MIME::Lite's shortcomings
if( $headers{ "Content-Type" } !~ /boundary/ ) {
$headers{ "Content-Type" } =
$headers{ "Content-Type" } .
qq{; boundary="} .
$msg->{ SubAttrs }->{ "content-type" }->{ boundary } .
qq{"};
}
return \%headers, $msg->body_as_string;
}
text => 'This is an <b>HTML</b> email.'
);
This will create two attachments, the first one as plain text
(generated by HTML::Text to the best of its abilities), followed by
the specified HTML message marked as content-type C<text/html>.
Non-HTML mail readers will pick up the first one, and Outlook-using
marketroids get fancy HTML. Everyone wins.
=head2 Test Mode
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Mail/DeliveryStatus/BounceParser.pm view on Meta::CPAN
my $orig_message_mime = MIME::Entity->build(Type => "multipart/transitory");
$orig_message_mime->add_part($self->{parser}->parse_data($orig_message));
$orig_message_mime->head->mime_attr("content-type" => "message/rfc822");
$newmessage->add_part($orig_message_mime);
$self->log("created new plain-report message.");
return $newmessage;
lib/Mail/DeliveryStatus/BounceParser.pm view on Meta::CPAN
my $orig_message_mime
= MIME::Entity->build(Type => "multipart/transitory", Top => 0);
$orig_message_mime->add_part($self->{parser}->parse_data($orig_message));
$orig_message_mime->head->mime_attr("content-type" => "message/rfc822");
$newmessage->add_part($orig_message_mime);
$self->log("created new multipart-report message.");
return $newmessage;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Mail/Exchange/PidTagDefs.pm view on Meta::CPAN
0x3709 => { type => 0x0102, name => "PidTagAttachRendering" }, # Contains a Windows Metafile, as specified in [MS-WMF], for the Attachment object.
0x370a => { type => 0x0102, name => "PidTagAttachTag" }, # Contains the identifier information for the application that supplied the Attachment object data.
0x370b => { type => 0x0003, name => "PidTagRenderingPosition" }, # Represents an offset, in rendered characters, to use when rendering an attachment within the main message text.
0x370c => { type => 0x001f, name => "PidTagAttachTransportName" }, # Contains the name of an attachment file, modified so that it can be correlated with TNEF messages.
0x370d => { type => 0x001f, name => "PidTagAttachLongPathname" }, # Contains the fully-qualified path and file name with extension.
0x370e => { type => 0x001f, name => "PidTagAttachMimeTag" }, # Contains a content-type MIME header.
0x370f => { type => 0x0102, name => "PidTagAttachAdditionalInformation" }, # Contains attachment encoding information.
0x3711 => { type => 0x001f, name => "PidTagAttachContentBase" }, # Contains the base of a relative URI.
0x3712 => { type => 0x001f, name => "PidTagAttachContentId" }, # Contains a content identifier unique to the Message object that matches a corresponding "cid:" URI schema reference in the HTML body of the Message object.
0x3713 => { type => 0x001f, name => "PidTagAttachContentLocation" }, # Contains a relative or full URI that matches a corresponding reference in the HTML body of a Message object.
0x3714 => { type => 0x0003, name => "PidTagAttachFlags" }, # Indicates which body formats might reference this attachment when rendering data.
0x3719 => { type => 0x001f, name => "PidTagAttachPayloadProviderGuidString" }, # Contains the GUID of the software component that can display the contents of the message.
0x371a => { type => 0x001f, name => "PidTagAttachPayloadClass" }, # Contains the class name of an object that can display the contents of the message.
0x371b => { type => 0x001f, name => "PidTagTextAttachmentCharset" }, # Specifies the character set of an attachment received via MIME with the content-type of text.
0x3900 => { type => 0x0003, name => "PidTagDisplayType" }, # Contains an integer value that indicates how to display an Address Book object in a table or as an addressee on a message.
0x3902 => { type => 0x0102, name => "PidTagTemplateid" }, #
0x3905 => { type => 0x0003, name => "PidTagDisplayTypeEx" }, # Contains an integer value that indicates how to display an Address Book object in a table or as a recipient (1) on a message.
0x39fe => { type => 0x001f, name => "PidTagSmtpAddress" }, # Contains the SMTP address of the Message object.
0x39ff => { type => 0x001f, name => "PidTagAddressBookDisplayNamePrintable" }, # Contains the printable string version of the display name.
view all matches for this distribution
view release on metacpan or search on metacpan
t/msg/multipart-signed-qp.eml view on Meta::CPAN
Received: by yx-out-2324.google.com with SMTP id 8so1539394yxb.51
for <chalpin@cs.wisc.edu>; Sun, 17 May 2009 20:34:25 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=gamma;
h=domainkey-signature:received:received:sender:from:to:subject:date
:user-agent:mime-version:content-type:content-transfer-encoding
:message-id;
bh=mrCnj+peIRZyFKKUom45vtHHHalEHjngUu8ydLdXIQI=;
b=Nos28h4Ki/p8AmLuXUIXnY08sJVz5cZfP7iobo92FgBcAaISCSmb+j/226Ei+CM1cN
E/379QNgPRWBM0YC7x6zP5U4BfI7HBYnZEjm5LVOrQZuMYavm62xesV8Yq/wMeRSmNiO
wlhgPUBIWpJa25vLEGPFSAY+xeYhS45LTQj94=
DomainKey-Signature: a=rsa-sha1; c=nofws;
d=gmail.com; s=gamma;
h=sender:from:to:subject:date:user-agent:mime-version:content-type
:content-transfer-encoding:message-id;
b=G74tCLyIQKXgrQXPzZF94Mu3MBiPsEAYsLOz8YvF6tSVpv1DmfnBPJHznKvXtXt+vR
vPizFC34icWwnEdzfLZ8q9qh3QWjpGRpfJnv7sa5bFOKMCnRH37Ev9zGWrphhgiOKvuv
igizNl84V7Lb5mNiQc8hgdqbMPLIyVYRdli20=
Received: by 10.90.86.10 with SMTP id j10mr5493898agb.59.1242617665125;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Mail/IMAPTalk.pm view on Meta::CPAN
my $Result = $IMAP->getannotation('user.joe.blah', '/*' '*') || die "IMAP error: $@";
$Result = {
'user.joe.blah' => {
'/vendor/cmu/cyrus-imapd/size' => {
'size.shared' => '5',
'content-type.shared' => 'text/plain',
'value.shared' => '19261'
},
'/vendor/cmu/cyrus-imapd/lastupdate' => {
'size.shared' => '26',
'content-type.shared' => 'text/plain',
'value.shared' => '26-Mar-2004 13:31:56 -0800'
},
'/vendor/cmu/cyrus-imapd/partition' => {
'size.shared' => '7',
'content-type.shared' => 'text/plain',
'value.shared' => 'default'
}
}
};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Mail/Make/Headers.pm view on Meta::CPAN
'in-reply-to' => 'In-Reply-To',
'references' => 'References',
'return-path' => 'Return-Path',
'received' => 'Received',
'mime-version' => 'MIME-Version',
'content-type' => 'Content-Type',
'content-transfer-encoding' => 'Content-Transfer-Encoding',
'content-disposition' => 'Content-Disposition',
'content-id' => 'Content-ID',
'content-description' => 'Content-Description',
};
lib/Mail/Make/Headers.pm view on Meta::CPAN
'message-id' => 100,
'in-reply-to' => 110,
'references' => 120,
'subject' => 130,
'mime-version' => 200,
'content-type' => 210,
'content-transfer-encoding' => 220,
'content-disposition' => 230,
'content-id' => 240,
'content-description' => 250,
};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Mail/Mbox/MessageParser/Grep.pm view on Meta::CPAN
my $endline = $self->{'endline'};
if (substr($self->{'READ_BUFFER'},$self->{'START_OF_EMAIL'},
$self->{'START_OF_BODY'}-$self->{'START_OF_EMAIL'}) =~
/^(content-type: *multipart[^\n\r]*$endline( [^\n\r]*$endline)*)/im)
{
my $content_type_header = $1;
$content_type_header =~ s/$endline//g;
if ($content_type_header =~ /boundary *= *"([^"]*)"/i ||
view all matches for this distribution