This script is a snippet which can be used to send an text email using perl programming.

This is useful code for the Perl programmer which needs to automate the application as well email application in the script itself

Just copy the below script and modify the email body along with sender and receiver inforamtion. you should be all set.

We are using sendmail command which is present in /usr/sbin.

Script

#!/usr/bin/perl

my $EMAIL_BODY="MY EMAIL BODY";

my $EMAIL_TO="This email address is being protected from spambots. You need JavaScript enabled to view it.";

my $sendmail = "/usr/sbin/sendmail -t -v";

my $reply_to = "Reply-to: xx";

my $from = "From: xxa";

my $SUBJECT_AUX="Subject: Your Subjectn";

my $send_to = "To: ".$EMAIL_TO."n";

open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";

print SENDMAIL $send_to;

print SENDMAIL $from;

print SENDMAIL $reply_to;

print SENDMAIL $SUBJECT_AUX;

print SENDMAIL "Content-type: text/plainnn";

print SENDMAIL $EMAIL_BODY;

close(SENDMAIL);


Like it on Facebook, Tweet it or share this article on other bookmarking websites.

No comments