use Net::SMTP; sSendEmail('validrecipient@validdomain.com','validrecipient@validdomain.com','ssssssubject','bbbbbbody'); sub sSendEmail { my ($to,$from,$subject,@body) = @_; my $smtp = Net::SMTP->new('mail.validdomain.com', Debug => 1); die "Could not open SMTP connection $!" if (! defined $smtp); print "Connected to: ", $smtp->domain. "\n"; $smtp->auth('garykuipers@ondacom.biz','judge'); print "debug:before recipient\n"; $smtp->recipient($to); print "debug:after recipient\n"; $smtp->mail($from); $smtp->data(); $smtp->datasend("To: $to\n"); $smtp->datasend("From: $from\n"); $smtp->datasend("Subject: $subject\n"); $smtp->datasend("\n"); foreach my $line (@body) { $smtp->datasend("$line\n"); } print "debug:before dataend\n"; $smtp->dataend(); print "debug:before quit\n"; $smtp->quit; print "debug:after quit\n"; print "Mail sent to: |$to|\n"; }