Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sendmail module in LINUX

Status
Not open for further replies.

dan44

Programmer
Aug 28, 2000
1
IN
I am new to Perl working on LINUX Redhat 6.0 platform.
All the sample codes for sending a simple mail mention of the 'sendmail' module located at /usr/lib/sendmail or /usr/sbin/sendmail.

I am not aware whether we need to configure the sendmail module which comes with the LINUX (or Unix for that matter) for sending email .

Can someone aware of this kindly advice ??

The sample code I have used is shown as a crosscheck.


#!/usr/bin/perl
use CGI;

my $query = new CGI;
my $sendmail = "/usr/sbin/sendmail -t"; #=> path of #sendmail module in My LINUX Redhat.

my $reply_to = "Reply-to: foo@bar.org";
my $subject = "Subject: Confirmation of your submission";
my $content = "Thanks for your submission.";
my $to = $query->param('send_to');
my $file = "subscribers.txt";

unless ($to) {
print $query->header;
print "Please fill in your email and try again";
}

open (FILE, ">>$file") or die "Cannot open $file: $!";
print $to,"\n";
close(FILE);

my $send_to = "To: ".$query->param('send_to');

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

print $query->header;
print "Confirmation of your submission will be emailed to you.";

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top