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.";
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"
print $to,"\n";
close(FILE);
my $send_to = "To: ".$query->param('send_to');
open(SENDMAIL, "|$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.";