Contact Us

Scripts: Perl :: Mail functions :: Library Article #2

Developer's Section

Send Mail using Perl
By: Erobo Team Member

Hire a Developer for Related Work / Installation | $55 hr
Rating:  | Rate It:   
Average Votes: (3037)

Use this simple technique to send an mail using PERL.

This article describes how to send mail using perl. Note: You must have enabled the perl mail program /usr/sbin/sendmail.
If your server is Linux you should have enabled the program by default.
Use the following function to send mail using perl:

 Code Snippet 1

#!/usr/bin/perl -w 

my $newmail = "/usr/sbin/sendmail -t";
my $reply_to = "Reply-to:\n";
my $subject = "Subject: Confirmation of your submission\n";
my $content = "Thanks for your submission."; 
my $to = "";
my $file = "subscribers.txt"; 

unless ($to) { print "Please enter all information available"; } 

open(SENDMAIL, "|$newmail") or die "Cannot open $newmail: $!"; 
print SENDMAIL $reply_to;
print SENDMAIL $subject;
print SENDMAIL $send_to;
print SENDMAIL "Content-type: text/plain\n\n";
print SENDMAIL $content;

See other Scripts in Mail functions

Submit Your Scripts:

System Message:
  • Your Perl script has been sent. Please allow 48 hours for processing.

If you would like to have your Perl scripts published in this section please fill out
the form below:
*Your Name or Username:
Home Town:
*Description and Code:
*Enter Code shown
to the right:

[ Refresh Image ]