0

Perl mail script

Wednesday, November 7, 2007

#!/usr/bin/perl

# This is a simple script to test sendmail.
# Replace "me" with a from address and "mydom.com" with the #sending domain.
# Replace "you" with a username to send to and "yourdom.com" #with the recipient's domain name.
# Upload this to the public_html folder as mailtest.pl and CHMOD it to 755
print "Content-type: text/plain\n\n";
unless(open (MAIL, "|/usr/sbin/sendmail -t")) {
print "error.\n";
warn "Error starting sendmail: $!";
}
else{
print MAIL "From: me\@mydom.com\n";
print MAIL "To: you\@yourdom.com\n";
print MAIL "Subject: test subject\n\n";
print MAIL "Perl Sendmail is working, please check your code.";
close(MAIL) || warn "Error closing mail: $!";
print "Mail sent.\n";

}

0 Responses to "Perl mail script"