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

Hi guys !!!
Its me again, I am working in a program to send an email
I was looking in CPAN and MAIL::Sendmail is what I use
so I copy the example and modify it a little bit for my
things, but I need to send an email to gmail or hotmail and
and evertime I got an error message like this
Error sending mail: RCPT TO: error (550 5.7.1
... Relaying denied. Proper authentication
required.)
Is there a better way to send an email but most important to send it to a hotmail or gmail account? thanks padawanlinuxero@gmail.com
use Mail::Sendmail; $Mail::Sendmail::VERSION\n"; [0]\n"; %mail = ( To => 'a.gz@at.com', From => 'a.gz@at.com', Cc => 'a@gmail.com', Subject => 'Test message', 'X-Mailer' => "Mail::Sendmail version $Mail::Sendmail::VERSION", ); $mail{Smtp} = 'sis.at.com'; $mail{'X-custom'} = 'My custom additionnal header'; $mail{'mESSaGE : '} = "The message key looks terrible, but works."; $mail{Date} = Mail::Sendmail::time_to_date( time() - 86400 ); 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: Send email error
by perlfan (Parson) on Oct 16, 2007 at 16:18 UTC
    That sounds like your smtp server is not allowing you to relay mail with out authenticating with it - is this just for gmail/hotmail, or for all email addresses? (my guess is the latter)
      Yes you are right to any email "inside" sis.at.com I can send email
      but if I try to send it to an external email
      like padawanlinuxero@gmail.com is giving me the same error message
      how can I fix this problem can you help me?
      Thanks

        If your SMTP server requires authentication to send to outside hosts then you can't using Mail::Sendmail. If you read the documentation (the section entitled LIMITATIONS) it specifically says it doesn't support SMTP auth. Switch to another mail sending module which does support authentication, or bribe and/or coerce your mail admin into letting the source box in question send mail to outside hosts without authentication.

        How do you normally send email from that host?

        If it's a linux box, it probably has sendmail locally. That's the SMTP server you'd use.

        If it's Windows you'd probably use a remote SMTP server to relay your traffic. Check the config of a working email client and you'll probably see how it's handled in your environment.

Re: Send email error
by jdporter (Paladin) on Oct 16, 2007 at 16:15 UTC

    That error is coming from your smtp host, sis.at.com. I guess you need to find a smtp host who will allow you to send mail through them.

Re: Send email error
by dwm042 (Priest) on Oct 16, 2007 at 18:28 UTC
    My suggestion is as follows:

    From a command prompt, (unix or Win32) type:
    telnet sis.at.com 25

    you may have to use port 587, YMMV.
    When it replies, type:
    EHLO

    Then note what kinds of authentication the relay supports. Then type:
    QUIT

    Of course, you could just call support at at.com and ask them. That should work as well.