GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  MAIL::INTERNET (3)

.ds Aq ’

NAME

Mail::Internet - manipulate email messages

CONTENTS

SYNOPSIS



  use Mail::Internet;
  my $msg = Mail::Internet->new(\*STDIN);



DESCRIPTION

This package implements reading, creating, manipulating, and writing email messages. Sometimes, the implementation tries to be too smart, but in the general case it works as expected.

If you start writing a <B>new applicationB>, you should use the Mail::Box distribution, which has more features and handles messages much better according to the RFCs. See <http://perl.overmeer.net/mailbox/>. You may also chose MIME::Entity, to get at least some multipart support in your application.

METHODS

    Constructors

$obj-><B>dupB>() Duplicate the message as a whole. Both header and body will be deep-copied: a new Mail::Internet object is returned.
$obj-><B>extractB>(ARRAY-of-LINES) Extract header and body from an ARRAY of message lines. Requires an object already created with new(), which contents will get overwritten.
$obj-><B>newB>( [ARG], [OPTIONS] )
Mail::Internet-><B>newB>( [ARG], [OPTIONS] ) ARG is optional and may be either a file descriptor (reference to a GLOB) or a reference to an array. If given the new object will be initialized with headers and body either from the array of read from the file descriptor.

The Mail::Header::new() OPTIONS Modify, MailFrom and FoldLength may also be given.



 -Option--Default
  Body    []
  Header  undef



Body => ARRAY-of-LINES The value of this option should be a reference to an array which contains the lines for the body of the message. Each line should be terminated with \n (LF). If Body is given then Mail::Internet will not attempt to read the body from ARG (even if it is specified).
Header => Mail::Header The value of this option should be a Mail::Header object. If given then Mail::Internet will not attempt to read a mail header from ARG, if it was specified.
$obj-><B>readB>(FILEHANDLE) Read a message from the FILEHANDLE into an already existing message object. Better use new() with the FILEHANDLE as first argument.

    Accessors

$obj-><B>bodyB>( [BODY] ) Returns the body of the message. This is a reference to an array. Each entry in the array represents a single line in the message.

If BODY is given, it can be a reference to an array or an array, then the body will be replaced. If a reference is passed, it is used directly and not copied, so any subsequent changes to the array will change the contents of the body.

$obj-><B>headB>() Returns the Mail::Header object which holds the headers for the current message

    Processing the message as a whole

$obj-><B>as_mbox_stringB>( [ALREADY_ESCAPED] ) Returns the message as a string in mbox format. ALREADY_ESCAPED, if given and true, indicates that escape_from() has already been called on this object.
$obj-><B>as_stringB>() Returns the message as a single string.
$obj-><B>printB>( [FILEHANDLE] ) Print the header, body or whole message to file descriptor FILEHANDLE. $fd should be a reference to a GLOB. If FILEHANDLE is not given the output will be sent to STDOUT.

example:



    $mail->print( \*STDOUT );  # Print message to STDOUT



$obj-><B>print_bodyB>( [FILEHANDLE] ) Print only the body to the FILEHANDLE (default STDOUT).
$obj-><B>print_headerB>( [FILEHANDLE] ) Print only the header to the FILEHANDLE (default STDOUT).

    Processing the header

Most of these methods are simply wrappers around methods provided by Mail::Header.
$obj-><B>addB>(PAIRS-of-FIELD) The PAIRS are field-name and field-content. For each PAIR, Mail::Header::add() is called. All fields are added after existing fields. The last addition is returned.
$obj-><B>combineB>( TAG, [WITH] ) See Mail::Header::combine().
$obj-><B>deleteB>( TAG, [TAGs] ) Delete all fields with the name TAG. Mail::Header::delete() is doing the work.
$obj-><B>foldB>( [LENGTH] ) See Mail::Header::fold().
$obj-><B>fold_lengthB>( [TAG], [LENGTH] ) See Mail::Header::fold_length().
$obj-><B>getB>( TAG, [TAGs] ) In LIST context, all fields with the name TAG are returned. In SCALAR context, only the first field which matches the earliest TAG is returned. Mail::Header::get() is called to collect the data.
$obj-><B>headerB>( [ARRAY-of-LINES] ) See Mail::Header::header().
$obj-><B>replaceB>(PAIRS-of-FIELD) The PAIRS are field-name and field-content. For each PAIR, Mail::Header::replace() is called with INDEX 0. If a FIELD is already in the header, it will be removed first. Do not specified the same field-name twice.

    Processing the body

$obj-><B>remove_sigB>( [NLINES] ) Attempts to remove a users signature from the body of a message. It does this by looking for a line equal to -- within the last NLINES of the message. If found then that line and all lines after it will be removed. If NLINES is not given a default value of 10 will be used. This would be of most use in auto-reply scripts.
$obj-><B>signB>(OPTIONS) Add your signature to the body. remove_sig() will strip existing signatures first.



 -Option   --Default
  File       undef
  Signature  []



File => FILEHANDLE Take from the FILEHANDLE all lines starting from the first --.
Signature => STRING|ARRAY-of-LINES
$obj-><B>tidy_bodyB>() Removes all leading and trailing lines from the body that only contain white spaces.

    High-level functionality

$obj-><B>escape_fromB>() It can cause problems with some applications if a message contains a line starting with `From , in particular when attempting to split a folder. This method inserts a leading `’> on any line that matches the regular expression /^*From/>
$obj-><B>nntppostB>( [OPTIONS] ) Post an article via NNTP. Requires Net::NNTP to be installed.



 -Option--Default
  Debug   <false>
  Host    <required>
  Port    119



Debug => BOOLEAN Debug value to pass to Net::NNTP, see Net::NNTP
Host => HOSTNAME|Net::NNTP object Name of NNTP server to connect to, or a Net::NNTP object to use.
Port => INTEGER Port number to connect to on remote host
$obj-><B>replyB>(OPTIONS) Create a new object with header initialised for a reply to the current object. And the body will be a copy of the current message indented.

The .mailhdr file in your home directory (if exists) will be read first, to provide defaults.



 -Option  --Default
  Exclude   []
  Indent    >
  Keep      []
  ReplyAll  false



Exclude => ARRAY-of-FIELDS Remove the listed FIELDS from the produced message.
Indent => STRING Use as indentation string. The string may contain %% to get a single %, %f to get the first from name, %F is the first character of %f, %l is the last name, %L its first character, %n the whole from string, and %I the first character of each of the names in the from string.
Keep => ARRAY-of-FIELDS Copy the listed FIELDS from the original message.
ReplyAll => BOOLEAN Automatically include all To and Cc addresses of the original mail, excluding those mentioned in the Bcc list.
$obj-><B>sendB>( [TYPE, [ARGS...]] ) Send a Mail::Internet message using Mail::Mailer. TYPE and ARGS are passed on to Mail::Mailer::new().
$obj-><B>smtpsendB>( [OPTIONS] ) Send a Mail::Internet message using direct SMTP. to the given ADDRESSES, each can be either a string or a reference to a list of email addresses. If none of To, <Cc> or Bcc are given then the addresses are extracted from the message being sent.

The return value will be a list of email addresses that the message was sent to. If the message was not sent the list will be empty.

Requires Net::SMTP and Net::Domain to be installed.



 -Option  --Default
  Bcc       undef
  Cc        undef
  Debug     <false>
  Hello     localhost.localdomain
  Host      $ENV{SMTPHOSTS}
  MailFrom  Mail::Util::mailaddress()
  Port      25
  To        undef



Bcc => ADDRESSES
Cc => ADDRESSES
Debug => BOOLEAN Debug value to pass to Net::SMPT, see <Net::SMTP>
Hello => STRING Send a HELO (or EHLO) command to the server with the given name.
Host => HOSTNAME Name of the SMTP server to connect to, or a Net::SMTP object to use

If Host is not given then the SMTP host is found by attempting connections first to hosts specified in $ENV{SMTPHOSTS}, a colon separated list, then mailhost and localhost.

MailFrom => ADDRESS The e-mail address which is used as sender. By default, Mail::Util::mailaddress() provides the address of the sender.
Port => INTEGER Port number to connect to on remote host
To => ADDRESSES
$obj-><B>unescape_fromB>(()) Remove the escaping added by escape_from().

SEE ALSO

This module is part of the MailTools distribution, http://perl.overmeer.net/mailtools/.

AUTHORS

The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance without commitment to further development.

Mail::Cap by Gisle Aas <aas@oslonett.no>. Mail::Field::AddrList by Peter Orbaek <poe@cit.dk>. Mail::Mailer and Mail::Send by Tim Bunce <Tim.Bunce@ig.co.uk>. For other contributors see ChangeLog.

LICENSE

Copyrights 1995-2000 Graham Barr <gbarr@pobox.com> and 2001-2007 Mark Overmeer <perl@overmeer.net>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 MAIL::INTERNET (3) 2014-11-21

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.