Index: req-config
===================================================================
RCS file: /cvsroot/its/sw/wreq/req-config,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -u -r1.3 -r1.4
--- req-config	1999/05/15 10:20:04	1.3
+++ req-config	1999/05/15 10:41:24	1.4
@@ -11,6 +11,9 @@
 #### How to call sendmail on your system
 $sendmail="/usr/lib/sendmail -oi"; # will -db make the page faster to return?
 
+#### If $sendmail is '', relay mails thru this host
+$mailhost='mailhost';
+
 #### The From address for errors in processing email requests
 #### Note: to prevent mail looping, this address doesn't actually exist.
 $error_from="Support Online Error <req-error\@localhost>";
Index: req-common
===================================================================
RCS file: /cvsroot/its/sw/wreq/req-common,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -u -r1.1 -r1.2
--- req-common	1999/05/09 21:51:08	1.1
+++ req-common	1999/05/15 10:41:24	1.2
@@ -445,8 +445,8 @@
 sub sendMail {# . 0from 1reply-to 2tos 3ccs 4subject 5message
 	if(!$_[2]){return;} # no one to send to
 
-	my $header=''; my $fflag=''; my $to='';
-	if($_[0]){$header.="From: $_[0]\n";}
+	my $header=''; my $fflag=''; my $to=''; my $from='';
+	if($_[0]){$header.="From: $_[0]\n"; $from ="$_[0]";}
 	if($_[2]){$header.="To: $_[2]\n"; $to="$_[2]";}
 	if($_[4]){$header.="Subject: $_[4]\n";}
 	if($_[3]){$header.="Cc: $_[3]\n"; $to.=",$_[3]";}
@@ -455,6 +455,7 @@
 	$header.="\n$_[5]\n"; # the body
 	
 	eval {
+	    if ($sendmail) {
 		# note from/tos can be of the form: aa bb <a@b>
 		open(POUT,"|$sendmail $fflag \"$to\">/dev/null 2>&1") || &html_error("cannot run sendmail: $!");
 		# redirect above  so it won't mess up the http header, eval{} works too.
@@ -465,6 +466,23 @@
 		### -n option should not be used, since we are sending to aliases.
 		print POUT "$header";
    		close (POUT);
+            } else {
+		eval 'use Net::SMTP;';
+		$smtp = Net::SMTP->new($mailhost,
+				       Timeout => 30); # seconds
+		if ($smtp) {
+		    $smtp->mail($from);
+		    for $user (split(/,/, $to)) {
+			$smtp->to($user);
+		    }
+		    $smtp->data();
+		    $smtp->datasend($header);
+		    $smtp->dataend();
+		    $smtp->quit;
+		} else {
+		    &html_error("sendMail: SMTP connect to $mailhost failed");
+		}
+	    }
     };
     &html_error("sendMail: $@") if $@;
 } 
Index: req-mail
===================================================================
RCS file: /cvsroot/its/sw/wreq/req-mail,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -u -r1.3 -r1.4
--- req-mail	1999/05/15 10:22:44	1.3
+++ req-mail	1999/05/15 10:41:24	1.4
@@ -264,8 +264,8 @@
 sub sendMail {# . 0from 1reply-to 2tos 3ccs 4subject 5message
 	if(!$_[2]){return;} # no one to send to
 
-	my $header=''; my $fflag=''; my $to='';
-	if($_[0]){$header.="From: $_[0]\n";}
+	my $header=''; my $fflag=''; my $to=''; my $from='';
+	if($_[0]){$header.="From: $_[0]\n"; $from ="$_[0]";}
 	if($_[2]){$header.="To: $_[2]\n"; $to="$_[2]";}
 	if($_[4]){$header.="Subject: $_[4]\n";}
 	if($_[3]){$header.="Cc: $_[3]\n"; $to.=",$_[3]";}
@@ -274,6 +274,7 @@
 	$header.="\n$_[5]\n"; # the body
 	
 	eval {
+	    if ($sendmail) {
 		# note from/tos can be of the form: aa bb <a@b>
 		open(POUT,"|$sendmail $fflag \"$to\">/dev/null 2>&1") || &html_error("cannot run sendmail: $!");
 		# redirect above  so it won't mess up the http header, eval{} works too.
@@ -284,6 +285,23 @@
 		### -n option should not be used, since we are sending to aliases.
 		print POUT "$header";
    		close (POUT);
+            } else {
+		eval 'use Net::SMTP;';
+		$smtp = Net::SMTP->new($mailhost,
+				       Timeout => 30); # seconds
+		if ($smtp) {
+		    $smtp->mail($from);
+		    for $user (split(/,/, $to)) {
+			$smtp->to($user);
+		    }
+		    $smtp->data();
+		    $smtp->datasend($header);
+		    $smtp->dataend();
+		    $smtp->quit;
+		} else {
+		    &html_error("sendMail: SMTP connect to $mailhost failed");
+		}
+	    }
     };
     &html_error("sendMail: $@") if $@;
 } 
