Sunday, 10 August 2008

Perl mail script

#!/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/plainnn";
unless(open (MAIL, "|/usr/sbin/sendmail -t")) {
print "error.n";
warn "Error starting sendmail: $!";
}
else{
print MAIL "From: me@mydom.comn";
print MAIL "To: you@yourdom.comn";
print MAIL "Subject: test subjectnn";
print MAIL "Perl Sendmail is working, please check your code.";
close(MAIL) || warn "Error closing mail: $!";
print "Mail sent.n";

}

No comments:

Post a Comment