• Home
  • Services
    • Consultancy
    • Custom Software Solutions
    • Systems Adminsitration
    • Web Applications
    • Customers
  • SCM
    • Clearcase
      • Triggers
      • Evil Twin Finder
      • GUI DiffBL
      • View Ager
      • Open Source Builds
    • Clearquest
      • Clearquest Daemon
      • DB Conversions
    • Git
      • Repository
  • Scripting
    • Perl
    • ECRDig
  • Sysadm
    • Environment
  • About
    • Services
    • Our People
    • Contact Us
 

ClearSCM Inc.

You are viewing an unstyled version of this page. Either your browser does not support Cascading Style Sheets (CSS) or CSS styling has been disabled.

NAME Mail.pm

A simplified approach to sending email

VERSION

Author

Andrew DeFaria <Andrew@ClearSCM.com>

Revision

Revision 1.34

Created

Thu Jan 5 15:15:29 PST 2006

Modified

Modifed 2012/09/25 01:34:10

SYNOPSIS

Conveniently send email.

  my $msg = "<h1>The Daily News</h1><p>Today in the news...</p>";

  mail (
    to          => "somebody\@somewhere.com",
    cc          => "sombody_else\@somewhere.com",
    subject     => "Today's News",
    mode        => "html",
    data        => $msg,
  );

  open STATUS_REPORT, "status.html";

  mail (
    to          => "boss\@mycompany.com",
    bcc         => "mysecret\@mailbox.com",
    subject     => "Weekly Status Report",
    data        => STATUS_REPORT,
    footing     => "Another day - Another dollar!"
  );

  close STATUS_REPORT;

DESCRIPTION

Sending email from Perl scripts is another one of those things that is often reinvented over and over. Well... This is yet another reinvention I guess. The goal here is to allow for a simplifed approach to sending email while still allowing MIME or rich text email to be sent.

Additionally a multipart (plain text and HTML'ized) email will be send if mode is set to html. Finally, if attempting to send HTML mail, if we cannot find the appropriate dependent modules we'll fall back to plain text only.

ROUTINES

The following routines are exported:

mail (<parms>)

Send email. The following OO style arguments are supported:

from

The from email address. If not specified then defaults to $ENV{SMTPFROM}.

to

Comma separated list of email addresses to set the mail to. At least one address must be specified.

cc

Comma separated list of email addresses to cc the mail to.

bcc

Comma separated list of email addresses to bcc the mail to.

subject

Subject line for email (Default: "(no subject)")

mode

Mode to send the email as. Values can be "plain", "text/plain", "html", "text/html".

randomizeFrom

Generate a random From email address.

data

Either a scalar that contains the message or a filehandle to an open file which contains the message. Can contain HTML if mode = HTML.

heading

Text to be included at the beginning of the email message. Can contain HTML if mode = HTML.

footing

Text to be included at the end fo the email message. Can contain HTML if mode = HTML.

Returns:

Nothing

CONFIGURATION AND ENVIRONMENT

SMTPHOST: Set to the appropriate mail server

SMTPFROM: Set to a from address to be used as a default

DEPENDENCIES

Perl Modules

Net::SMTP

File::Basename

CPAN Modules

(Optionally - i.e. if html email is requested:)

MIME::Entity

HTML::Parser

HTML::FormatText

HTML::TreeBuilder

ClearSCM Perl Modules

Display

GetConfig

INCOMPATABILITIES

None yet...

BUGS AND LIMITATIONS

There are no known bugs in this module.

Please report problems to Andrew DeFaria >Andrew@ClearSCM.com>.

LICENSE AND COPYRIGHT

This Perl Module is freely available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This Perl Module is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (http://www.gnu.org/copyleft/gpl.html) for more details.

You should have received a copy of the GNU General Public License along with this Perl Module; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. reserved.