in reply to Module for smtp mail server?
Just call this by &smtp('mail message');use Net::SMTP; $from = "SMSrobot"; $to = "me\@mydomai.com"; $smtp_retry = "3"; $smtp_timeout = "60"; $smtp_server = "smtp.provider.com"; # -------------------------------------------------------------------- +----- #sub smtp sub smtp { my ( $message ) = @_[0]; &logging("Conecting to $smtp_server SMTP server..."); unless ( $smtp = Net::SMTP->new( $smtp_server, Hello => $from, Tim +eout => $smtp_timeout ) ) { &logging("Can't connect."); return 0; } &logging("Conected."); unless ( $smtp->mail( $from ) and $smtp->to( $to ) ) { &logging("Can't initialize communication"); return 0; } &logging("Sending mail to $to"); unless ( $smtp->data() and $smtp->datasend("$message\n") and $smtp +->dataend() and $smtp->quit) { &logging("Can't send data."); return 0; } $message =~ s/\s/ /isg; &logging("Message: \"$message\" was sent."); &logging("Quit."); return 1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Module for smtp mail server?
by Anonymous Monk on Mar 16, 2001 at 22:50 UTC |