use Net::SMTP; use MIME::Base64; # usage: sendmail(mailserver,username,password,from,to,subject,content,debug); sub sendmail { my ($mail_server,$username,$password,$from,$to,$subject,$content,$debug)=@_; $smtp = Net::SMTP->new( $mail_server, Timeout => 30, Debug => $debug, ); $smtp->datasend("AUTH LOGIN\n"); $smtp->response(); $smtp->datasend(encode_base64($username)); $smtp->response(); $smtp->datasend(encode_base64($password)); $smtp->response(); $smtp->mail($from); $smtp->to($to); $smtp->data(); $smtp->datasend("To: $to\n"); $smtp->datasend("From: $from\n"); $smtp->datasend("Content-Type: text/html\n"); $smtp->datasend("Subject: $subject"); $smtp->datasend("\n"); $smtp->datasend($content); $smtp->datasend("\n"); $smtp->dataend(); $smtp->quit; }