connect to localhost failed error with Mail::Sendmail on Windows

Discussion in 'Perl Misc' started by ++imanshu, Nov 8, 2009.

  1. ++imanshu

    ++imanshu Guest

    Hi,

    I am trying the example script of Mail::Sendmail with ActivePerl
    on windows pc connected to the internet:-

    ---
    - trying localhost
    - connect to localhost failed (Unknown error)
    retrying in 1 seconds...
    - connect to localhost failed, next server...
    connect to localhost failed (Unknown error)
    connect to localhost failed
    connect to localhost failed (Unknown error) no (more) retries!
    ---

    This is the script :-

    use Mail::Sendmail;

    %mail = ( To => '',
    From => '',
    Message => "This is a very short message",
    );

    sendmail(%mail) or die $Mail::Sendmail::error;

    print "OK. Log says:\n", $Mail::Sendmail::log;

    ---

    What can I set $mail{smtp} so that it works?

    Thank You,
    ++imanshu
    ++imanshu, Nov 8, 2009
    #1
    1. Advertising

  2. ++imanshu

    smallpond Guest

    On Nov 8, 6:39 am, "++imanshu" <> wrote:
    > Hi,
    >
    >      I am trying the example script of Mail::Sendmail with ActivePerl
    > on windows pc connected to the internet:-
    >
    > ---
    > - trying localhost
    > - connect to localhost failed (Unknown error)
    > retrying in 1 seconds...
    > - connect to localhost failed, next server...
    > connect to localhost failed (Unknown error)
    > connect to localhost failed
    > connect to localhost failed (Unknown error) no (more) retries!
    > ---
    >
    >      This is the script :-
    >
    >   use Mail::Sendmail;
    >
    >   %mail = ( To      => '',
    >             From    => '',
    >             Message => "This is a very short message",
    >           );
    >
    >   sendmail(%mail) or die $Mail::Sendmail::error;
    >
    >   print "OK. Log says:\n", $Mail::Sendmail::log;
    >
    > ---
    >
    >      What can I set $mail{smtp} so that it works?
    >
    > Thank You,
    > ++imanshu



    Installation instructions for Mail::Sendmail:

    "At the top of Sendmail.pm, set your default SMTP server(s),
    unless you specify it with each message, or want to use the
    default (localhost)."

    Default is that you are running an smtp mail program listening
    on your machine's smtp port. If you don't know what that is
    then you don't have one.

    Otherwise you need to have a server somewhere else that
    supports smtp. Usually, your isp will provide an smtp
    server like mail.myisp.net; see their support website.
    Some cheap isps now only provide web-based email, in which
    case you tell them to go get a new customer.
    smallpond, Nov 8, 2009
    #2
    1. Advertising

  3. ++imanshu

    Bart Lateur Guest

    ++imanshu wrote:

    >Hi,
    >
    > I am trying the example script of Mail::Sendmail with ActivePerl
    >on windows pc connected to the internet:-


    I think this module expects sendmail to be running on your computer, or
    on a computer in your local network, and with Windows, that's not very
    likely.

    Why aren't you using SMTP?

    If you use MIME::Lite, you can easily switch between the two, which is
    handy even if your mails aren't MIME mails.

    --
    Bart.
    Bart Lateur, Nov 8, 2009
    #3
  4. ++imanshu

    ++imanshu Guest

    On Nov 8, 11:03 pm, smallpond <> wrote:
    > On Nov 8, 6:39 am, "++imanshu" <> wrote:
    >
    >
    >
    > > Hi,

    >
    > >      I am trying the example script of Mail::Sendmail with ActivePerl
    > > on windows pc connected to the internet:-

    >
    > > ---
    > > - trying localhost
    > > - connect to localhost failed (Unknown error)
    > > retrying in 1 seconds...
    > > - connect to localhost failed, next server...
    > > connect to localhost failed (Unknown error)
    > > connect to localhost failed
    > > connect to localhost failed (Unknown error) no (more) retries!
    > > ---

    >
    > >      This is the script :-

    >
    > >   use Mail::Sendmail;

    >
    > >   %mail = ( To      => '',
    > >             From    => '',
    > >             Message => "This is a very short message",
    > >           );

    >
    > >   sendmail(%mail) or die $Mail::Sendmail::error;

    >
    > >   print "OK. Log says:\n", $Mail::Sendmail::log;

    >
    > > ---

    >
    > >      What can I set $mail{smtp} so that it works?

    >
    > > Thank You,
    > > ++imanshu

    >
    > Installation instructions for Mail::Sendmail:
    >
    > "At the top of Sendmail.pm, set your default SMTP server(s),
    > unless you specify it with each message, or want to use the
    > default (localhost)."


    yes I wrongly assumed smtp to be so simple that the module alone could
    handle it without another server. There were some EHLO, HELO strings
    in the pm file which reinforced my wrong assumption.

    >
    > Default is that you are running an smtp mail program listening
    > on your machine's smtp port.  If you don't know what that is
    > then you don't have one.


    now i understand that i do need one.

    >
    > Otherwise you need to have a server somewhere else that
    > supports smtp.  Usually, your isp will provide an smtp
    > server like mail.myisp.net; see their support website.
    > Some cheap isps now only provide web-based email, in which
    > case you tell them to go get a new customer.


    My ISP apparently provides relay but under another costlier plan!!

    Thank You,
    ++imanshu
    ++imanshu, Nov 9, 2009
    #4
  5. ++imanshu

    Uri Guttman Guest

    >>>>> "+" == ++imanshu <> writes:

    >> Otherwise you need to have a server somewhere else that
    >> supports smtp.  Usually, your isp will provide an smtp
    >> server like mail.myisp.net; see their support website.
    >> Some cheap isps now only provide web-based email, in which
    >> case you tell them to go get a new customer.


    +> My ISP apparently provides relay but under another costlier plan!!

    that makes no sense. do they even provide a basic email account? if they
    do, they must provide outgoing email service via an smtp
    server. relaying is if you need a server on your box and they would
    relay it elsewhere (or something similar than typical users would never
    need). so find out the name of the outgoing mail server and you can use
    it directly with most smtp modules on cpan. you don't need a local
    server to send mail if you isp allows you to have a mail account. you
    will likely need to provide an account name and password but most of the
    modules can handle that too.

    uri

    --
    Uri Guttman ------ -------- http://www.sysarch.com --
    ----- Perl Code Review , Architecture, Development, Training, Support ------
    --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
    Uri Guttman, Nov 9, 2009
    #5
  6. On 2009-11-09, Uri Guttman <> wrote:
    >>>>>> "+" == ++imanshu <> writes:

    *SKIP*
    > +> My ISP apparently provides relay but under another costlier plan!!
    >
    > that makes no sense.


    How this? That makes a perfect sense -- think about it from ISP's POV.
    The less features to implement the less expensive support (of those
    features) is. My previous ISP has gone even farer -- they just
    outsourced e-mail altogether (with me supposed to pay for anything more
    than webmail).

    > do they even provide a basic email account?


    Why they would? Google fits everyone.

    p.s. In fact, I pay for my e-mail; it's not that costly, but I pay.

    --
    Torvalds' goal for Linux is very simple: World Domination
    Stallman's goal for GNU is even simpler: Freedom
    Eric Pozharski, Nov 10, 2009
    #6
  7. On 2009-11-09 09:45, ++imanshu <> wrote:
    > On Nov 8, 11:03 pm, smallpond <> wrote:
    >> Installation instructions for Mail::Sendmail:
    >>
    >> "At the top of Sendmail.pm, set your default SMTP server(s),
    >> unless you specify it with each message, or want to use the
    >> default (localhost)."

    >
    > yes I wrongly assumed smtp to be so simple that the module alone could
    > handle it without another server.


    That doesn't make sense. A protocol specifies how two (or more) entities
    talk to each other. In the case of a client/server protocol like SMTP,
    how a client talks to a server. Since Mail::Sendmail implements an SMTP
    client (it is used to send mail, not to receive it), it needs an SMTP
    server to talk to.

    > There were some EHLO, HELO strings
    > in the pm file which reinforced my wrong assumption.


    Of course the module contains these strings. It needs to send them to
    the server.

    hp
    Peter J. Holzer, Nov 10, 2009
    #7
  8. ++imanshu

    Steve C Guest

    Peter J. Holzer wrote:
    > On 2009-11-09 09:45, ++imanshu <> wrote:
    >> On Nov 8, 11:03 pm, smallpond <> wrote:
    >>> Installation instructions for Mail::Sendmail:
    >>>
    >>> "At the top of Sendmail.pm, set your default SMTP server(s),
    >>> unless you specify it with each message, or want to use the
    >>> default (localhost)."

    >> yes I wrongly assumed smtp to be so simple that the module alone could
    >> handle it without another server.

    >
    > That doesn't make sense. A protocol specifies how two (or more) entities
    > talk to each other. In the case of a client/server protocol like SMTP,
    > how a client talks to a server. Since Mail::Sendmail implements an SMTP
    > client (it is used to send mail, not to receive it), it needs an SMTP
    > server to talk to.
    >


    It makes perfect sense. If you see a module called Sendmail, you think
    Hunh. Maybe this module sends mail.
    Don't beat up on the guy just for not knowing the guts of mail transport.
    It's an easy mistake to make.
    Steve C, Nov 10, 2009
    #8
  9. On 2009-11-10 21:04, Steve C <> wrote:
    > Peter J. Holzer wrote:
    >> On 2009-11-09 09:45, ++imanshu <> wrote:
    >>> On Nov 8, 11:03 pm, smallpond <> wrote:
    >>>> Installation instructions for Mail::Sendmail:
    >>>>
    >>>> "At the top of Sendmail.pm, set your default SMTP server(s),
    >>>> unless you specify it with each message, or want to use the
    >>>> default (localhost)."
    >>> yes I wrongly assumed smtp to be so simple that the module alone could
    >>> handle it without another server.

    >>
    >> That doesn't make sense. A protocol specifies how two (or more) entities
    >> talk to each other. In the case of a client/server protocol like SMTP,
    >> how a client talks to a server. Since Mail::Sendmail implements an SMTP
    >> client (it is used to send mail, not to receive it), it needs an SMTP
    >> server to talk to.

    >
    > It makes perfect sense. If you see a module called Sendmail, you think
    > Hunh. Maybe this module sends mail.


    That's what it does. It sends mail. So it's a client. Now you need
    something which receives mail. This is called an SMTP server.

    > Don't beat up on the guy just for not knowing the guts of mail transport.


    He knows enough to recognize EHLO as an SMTP keyword.

    hp
    Peter J. Holzer, Nov 10, 2009
    #9
  10. ++imanshu

    ++imanshu Guest

    On Nov 11, 4:14 am, Ben Morrow <> wrote:
    > Quoth "Peter J. Holzer" <>:
    >
    >
    >
    > > On 2009-11-09 09:45, ++imanshu <> wrote:
    > > > On Nov 8, 11:03 pm, smallpond <> wrote:
    > > >> Installation instructions for Mail::Sendmail:

    >
    > > >> "At the top of Sendmail.pm, set your default SMTP server(s),
    > > >> unless you specify it with each message, or want to use the
    > > >> default (localhost)."

    >
    > > > yes I wrongly assumed smtp to be so simple that the module alone could
    > > > handle it without another server.

    >
    > > That doesn't make sense. A protocol specifies how two (or more) entities
    > > talk to each other. In the case of a client/server protocol like SMTP,
    > > how a client talks to a server. Since Mail::Sendmail implements an SMTP
    > > client (it is used to send mail, not to receive it), it needs an SMTP
    > > server to talk to.

    >
    > It's not a priori obvious that Mail::Sendmail can't (and shouldn't)
    > perform MX lookups and deliver the mail directly to the appropriate
    > mailhost. OTOH, I would say anyone who *doesn't* know this (and why)
    > should not be writing programs which send mail...
    >
    > Ben


    Thanks for the replies. The beating is well deserved :D

    I understand that I need to go back to the books for this.

    Thank You,
    ++imanshu
    ++imanshu, Nov 11, 2009
    #10
  11. On 2009-11-11 09:42, ++imanshu <> wrote:
    > On Nov 11, 4:14 am, Ben Morrow <> wrote:
    >> Quoth "Peter J. Holzer" <>:
    >> > On 2009-11-09 09:45, ++imanshu <> wrote:
    >> > > On Nov 8, 11:03 pm, smallpond <> wrote:
    >> > >> Installation instructions for Mail::Sendmail:

    >>
    >> > >> "At the top of Sendmail.pm, set your default SMTP server(s),
    >> > >> unless you specify it with each message, or want to use the
    >> > >> default (localhost)."

    >>
    >> > > yes I wrongly assumed smtp to be so simple that the module alone could
    >> > > handle it without another server.

    >>
    >> > That doesn't make sense. A protocol specifies how two (or more) entities
    >> > talk to each other. In the case of a client/server protocol like SMTP,
    >> > how a client talks to a server. Since Mail::Sendmail implements an SMTP
    >> > client (it is used to send mail, not to receive it), it needs an SMTP
    >> > server to talk to.

    >>
    >> It's not a priori obvious that Mail::Sendmail can't (and shouldn't)
    >> perform MX lookups and deliver the mail directly to the appropriate
    >> mailhost.


    I could answer that in that case it still needs a server, it just
    determines the server from the recipient domain via DNS instead of from
    local configuration. But that would be nitpicking.

    Mail::Sendmail should be able to talk to an MX if you can configure that
    locally (which might make sense if you just want to send mail to a fixed
    address), but in general this isn't useful. It wants a local submission
    server which can then handle all the hard parts of mail transport,
    especially queueing and retries after temporary failures.

    >> OTOH, I would say anyone who *doesn't* know this (and why)
    >> should not be writing programs which send mail...

    >
    > Thanks for the replies. The beating is well deserved :D


    It wasn't meant as a beating. I was just puzzled how somebody who
    obviously knows enough about SMTP to recognize SMTP keywords could fail
    to recognize that Mail::Sendmail implements an SMTP client (or, more
    specifically, a SUBMISSION client) and therefore needs an SMTP server to
    talk to.

    hp
    Peter J. Holzer, Nov 11, 2009
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sugapablo
    Replies:
    0
    Views:
    2,150
    sugapablo
    Sep 21, 2007
  2. Andrzej Adam Filip
    Replies:
    0
    Views:
    4,078
    Andrzej Adam Filip
    Mar 31, 2008
  3. Andres Monroy-Hernandez
    Replies:
    1
    Views:
    168
    Tony Curtis
    Jun 28, 2003
  4. Jhary-a-Conel
    Replies:
    2
    Views:
    235
    Per Hedeland
    Jul 4, 2003
  5. Cameron Simpson
    Replies:
    0
    Views:
    102
    Cameron Simpson
    May 30, 2013
Loading...

Share This Page