gary kuipers has asked for the wisdom of the Perl Monks concerning the following question:

Need to send email via SMTP server that has username and password. Using MIME::Entity which uses smtpsend. The problem is I don't know how to pass the package the username and password. When I omit the "auth" line and use an SMTP server that does not require authentication this works like a charm.
sub sSendEmailMIME { use Mail::Internet; use MIME::Entity; my $retval = 0; my ($to,$from,$subject,$with,$encoding,$filename) = @_; if ( my $msg = MIME::Entity->build(From => $from, To => $to, Subject => $subject, Type => 'text/html', Encoding => "7bit", Path => "$filename", Filename => "$filename") ) { if ( $msg->smtpsend(Host => '') ) { $msg->auth ('','123abc'); $retval = 1; print "sent\n"; } else { print "send FAILED: $!\n"; } } return $retval; }
This invariably gives me a "send FAILED" without explanation.

Thanks for your help.


Replies are listed 'Best First'.
Re: Problem passing ESMTP username/password through MIME::Enity
by jlongino (Parson) on Jan 19, 2003 at 05:31 UTC
    I notice that where you should have a login/username you put an email address instead: "". Normally you would send just "me" as the login and then the password.

    I don't know if this will solve your problem or not, maybe when writing your post you typo'd the entire address instead of the login.