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

I have problems sending email because my SMTP server require authentication to allow email to be send out. The authentication is the email user name and password. Without authentication the following message appear :
Error sending to pieter.allaer@eu.valor.com (550 Relaying is prohibited)
Does anybody know how to pass the authentication when using Mail::Sendmail ?
Below a small example script

use Mail::Sendmail; my %mail; %mail = ( To => 'pieter.allaer@eu.valor.com', From => 'pieter.allaer@eu.valor.com', #Bcc => 'Someone <him@there.com>, Someone else her@there +.com', # only addresses are extracted from Bcc, real names disregar +ded #Cc => 'pieter.allaer@eu.valor.com', # Cc will appear in the header. (Bcc will not) Subject => "The neutral BOM file for $curJob{jobName} is cre +ated", 'X-Mailer' => "Mail::Sendmail version $Mail::Sendmail::VERSI +ON", ); $mail{Smtp} = 'euvalor.eu.valor.com'; $mail{'X-custom'} = 'My custom additionnal header'; $mail{'mESSaGE : '} = "Please process the Neutral BOM file which + can be found at $bommgr_scrub_save\n This is an automatic generated +email"; # cheat on the date: $mail{Date} = Mail::Sendmail::time_to_date( time() - 86400 ); sendmail %mail; #if (sendmail %mail) { print "Mail sent OK.\n" } #else { print "Error sending mail: $Mail::Sendmail::error \n" } #print "\n\$Mail::Sendmail::log says:\n", $Mail::Sendmail::log;

Replies are listed 'Best First'.
Re: How to pass authentication through Mail::Sendmail
by Rex(Wrecks) (Curate) on Sep 24, 2001 at 20:51 UTC
    Once again I drege this up from the "Network Programming with Perl", really, this book is a must :)

    Try Net::SMTP, it allows the use of AUTH in the options hash arg.

    "Nothing is sure but death and taxes" I say combine the two and its death to all taxes!
Re: How to pass authentication through Mail::Sendmail
by VSarkiss (Monsignor) on Sep 24, 2001 at 19:06 UTC

    Not really a Perl thing, but....

    The problem isn't authentication. Your sendmail server is configured not to act as an open relay, as evidenced by the 550 Relaying prohibited error code it's returning (that's a Good Thing, by the way). You're getting the error because your "from" address doesn't match the name of the host the server is running on. If you change the from address to be the host's correct name (localhost will do in a pinch), you should be OK.

    Disclaimer: it's been a number of years since I hacked on sendmail. ;-)

      The problem is related to authentication. If I would send an email to a person inside the network it will work OK because authentication is not required their but the moment I want to relay outside the network authentication is required and the user and password is checked to send email. If you look at email programs : outlook, eudora, they all provide an option to allow authentication when sending email and this is in most cases the user and password which is also used to check email.
      Note : If I use an SMTP server which is configured not to require authentication which nowadays you don't find anymore because nobody want allow anymore non-authorized people to use their SMTP server to send email because most people used non-secured SMTP servers for spamming purposes

        Greetings.

        It may be related to authentication, but...
        Authentication has not been part of (E)SMTP for a long time - an AUTH extension has been kicking around for a couple of years and sendmail has support for it starting from 8.10 (based on SASL). Other than that, some authentication has been provided through a hack called pop_before_smtp (similar to what you refer to).

        The short story is:

        1. You have to find out which method your site is using - $Mail::Sendmail::log may be helping you here;
        2. I doubt very much that Mail::Sendmail has support for either ESMTP AUTH or POP_BEFORE_SMTP, and that means you may have to roll your own (might be hard);
        3. Perhaps you can charm the postmaster to carve a hole in the relay rules, wide enough for your script to peep through - but don't count too much on it.
        Cheers,
        alf