Products
Services
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: (1838)
Favorites:

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: foo@request.com\n";
my $subject = "Subject: Confirmation of your submission\n";
my $content = "Thanks for your submission."; 
my $to = "someone@domain.com";
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;
close(SENDMAIL);


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:
*Email:
*Description and Code:
*Enter Code shown
to the right:

[ Refresh Image ]