# FILE: src-board-subs-smtp
#-------------------------------------------------------------------------------
# DISCUS VERSION 3.10 COPYRIGHT NOTICE
#
# Discus 3.10 is copyright (c) 2000 by DiscusWare, LLC, all rights reserved.
# The use of Discus is governed by the Discus License Agreement which is
# available from the Discus WWW site at:
#    http://www.discusware.com/discus/license
#
# Pursuant to the Discus License Agreement, this copyright notice may not be
# removed or altered in any way.
#-------------------------------------------------------------------------------

sub SMTP_send {
	my ($to, $bcc, $input, $debug, $subjectline, $replyto) = @_;
	use Net::SMTP;
	$status = ($smtp = Net::SMTP->new($email{"SMTP"}, Timeout => 30));
	if (!$status && $debug) {
		&error_message("SMTP connection error", "[1] Error connecting to $email{'SMTP'}! Be sure you've given the correct name for the SMTP server, that the SMTP server is turned on, and that the SMTP server actually has SMTP service running on it!") ;
	}
	if (!$smtp->mail($ENV{USER})) {
		&error_message("SMTP send error", "[2] Error sending data to $email{'SMTP'}: " . $smtp->message()) if $debug;
	}
	if (!$smtp->to($to)) {
		&error_message("SMTP send error", "[3] Error sending data to $email{'SMTP'}: " . $smtp->message()) if $debug;
	}
	$smtp->data();
	$smtp->datasend("To: $to\n");
	$smtp->datasend("Subject: $subjectline\n");
	$fr = $email{fromname};
	$fr .= " <$email{fromaddr}>" if $email{fromaddr};
	$smtp->datasend("From: $fr\n") if $fr;
	$smtp->datasend("Reply-to: $replyto\n") if $replyto;
	$dataX = "X-Mailer: Discus $release_version";
	$dataX .= ".$free_revision" if !$pro;
	$dataX .= ".$pro_revision Pro" if $pro;
	$dataX .= " <$html_url>\n";
	$smtp->datasend("$dataX");
	$smtp->datasend("\n");
	$smtp->datasend($input);
	$smtp->dataend();
	$status = $smtp->send();
	if ($status) {
		&error_message("SMTP send error", "[4] Error sending data to $email{'SMTP'}: " . $smtp->message()) if $debug;
	}
	$smtp->quit;
	return 1;
}

1;


# END - FILE IS CORRECTLY UPLOADED #
