sendmail Utility

Virtual Web servers at LiveZone are not configured for use with the standard UNIX sendmail command. This decision was made due to the long tradition of bugs and security problems with sendmail.

Instead, a replacement command has been installed in your Web site, that may be used in place of sendmail to send email from either Perl or shell scripts. This command is /cgi-bin/smptmail.pl

UNIX Command

To send email from a shell or Perl script, provide smtpmail.pl with a standard-input formetted as the email headers and body would normally appear. smptmail.pl will parse the email headers in its standard-input and send the email using a LiveZone SMTP server. Recipients of smtpmail.pl email will not notice anything unusual, and the email will appear to have been generated by sendmail or some other email authoring program.

A typically-formatted email is described below.

From: <address>
TO: <address> [,<address>] ... [,<address>]
CC: <address> [,<address>] ... [,<address>]
BCC: <address> [,<address>] ... [,<address>]
Subject: <text>

  1. The email body (content) begins on the first line that does not contain one of the headers described above, and ends with the end-of-file.
  2. <address> is any valid email address, often of the form name@domain.com
  3. Subject <text> is any sequence of printable ASCII characters
  4. Header labels from, to, cc, bcc, and subject are case-insensitive, and may be entered in any combination of upper and lower-case letters. Any white-space immediate to the right of a header's 'colon (:) are ignored.
  5. Header labels may appear in any order.
  6. There may be any number of addresses specified for to, cc, and bcc headers, and only a single address for the from header.
  7. No particular headers need be specified.
  8. If the from header is not specified, the server will indicate the mail is from MAILER-DAEMON@server8.LiveZone.net.
  9. Addresses specified in to and cc headers will be shown in the email being sent; addresses specified on a bcc header will be invisible to all receipients.

Shell Command Example

#!/usr/bin/sh
(
echo 'From: me@domain.com'
echo 'To: you@dom.com, them@dom.org'
echo 'BCC: her@dom.gov'
echo 'Subject: My files...'
echo 'hello there Fred'
echo 'here is my directory listing:'
echo ''
ls -l /directory/*
) | /cgi-bin/smtpmail.pl

Perl Command Example

#!/usr/bin/perl
open (PIPE, "| /cgi-bin/smtpmail.pl") or die "bad smptmail.pl";
print << EOF;
print 'From: me@domain.com', "\n";
print 'To: you@dom.com, them@dom.org', "\n";
print 'BCC: her@dom.gov', "\n";
print 'Subject: My files...', "\n";
print 'hello there Fred', "\n";
print 'my favorite number is ', 13 * 189 / 17, "\n";
close( PIPE );

Perl Subroutine

smtpmail.pl may also be used as a Perl library. Use the Perl "require" statement to include smtpmail.pl into your Perl script. The basic email subroutine to call is smtpmail(), which is described below:

# Usage:
# smtpmail( "me@myhouse.com",
# "toYou@yourhouse.com, toThem@theirhouse.com",
# "ccThem@somewhere.com, ccHim@hisHouse.org",
# "bccHer@herHouse.com, bccThem@theirHouse.org",
# "Mysubject",
# "My message" );
#
# Parameters:
# $from = email address of sender
# $to = email address(es) of receiver(s) -> shown on To: xxx header line
# $cc = email address(es) of receiver(s) -> shown on CC: xxx header line
# $bcc = email address(es) of receiver(s) -> not shown on any header line
# $subject = subject of message
# $messagebody = body of message (including newlines)
#
# Output:
# None

Perl Subroutine Example

#!/usr/bin/perl
my $favoriteNumber = 13 * 189 / 17;
smtpmail( 'me@domain.com', # From:
'you@dom.com, them@dom.org', # To:
'', # CC:
'her@dom.gov', # BCC:
'My files...', # Subject:
"hello there Fred\nmy favorite number is $favoriteNumber\n" );



www.LiveZone.net
   

To SupportZone Main Page

Last Updated Nov. 2009
Copyright (c) 1995-2009 by LiveZone Communications LLC. All rights reserved.
WomenZone, BusinessZone, SupportZone are trademarks of LiveZone Communications LLC.
LiveZone is a registered trademark of LiveZone Communications LLC.