sub SendMemberMail { my ($subject,$from,$to,$port,$cc,$bcc,$heading,$body,$closing,$signiture,$auth) = @_; # Open log for recording during execution of SendMail my $sendMail_logfile = '/home/abcus/public_html/httpsdocs/cgi-bin/lib/perl/Mail/mail.log'; open(my $fh, "+<", "$sendMail_logfile") or die "Opening: $!"; my $previous_STDOUT_fh = select(STDOUT); my $previous_STDERR_fh = select(STDERR); #Redirect STDERR & STDOUT to $fh for this sub *STDOUT = $fh; *STDERR = $fh; my $message = ($heading . "\n" . "\n" . $body . "\n" . "\n" . $closing . "\n" . "\n" . $signiture . "\n" ); if ($auth == 1) { $auth = {user=>'webmaster@abc.us', password=>'wm@xxxx', method=>'PLAIN LOGIN', REQUIRED=>1} } elsif ($auth == 0) { $auth = ""; } my %mail = ( To => $to, From => $from, Cc => $cc, Bcc => $bcc, Auth => $auth, Port => $port, Subject => $subject, Message => $message, debug => 18 ); SendMail(%mail) or die $Mail::sendMail::error; $log .= "Sending eMail Succeded\n"; #Print the data from the $log. print $fh $log; #restore the standard handles select($previous_STDOUT_fh); select($previous_STDERR_fh); close($fh); return 1; }