
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
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>
#!/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
#!/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 );
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
#!/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 |
Last Updated Nov. 2009 |