Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   connect to localhost failed error with Mail::Sendmail on Windows (http://www.velocityreviews.com/forums/t911743-connect-to-localhost-failed-error-with-mail-sendmail-on-windows.html)

++imanshu 11-08-2009 11:39 AM

connect to localhost failed error with Mail::Sendmail on Windows
 
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 => 'random.random@gmail.com',
From => 'random@yahoo.com',
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



smallpond 11-08-2009 05:03 PM

Re: connect to localhost failed error with Mail::Sendmail on Windows
 
On Nov 8, 6:39*am, "++imanshu" <himanshu.g...@gmail.com> 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 * * *=> 'random.ran...@gmail.com',
> * * * * * * From * *=> 'ran...@yahoo.com',
> * * * * * * 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.


Bart Lateur 11-08-2009 08:18 PM

Re: connect to localhost failed error with Mail::Sendmail on Windows
 
++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.

++imanshu 11-09-2009 09:45 AM

Re: connect to localhost failed error with Mail::Sendmail on Windows
 
On Nov 8, 11:03*pm, smallpond <smallp...@juno.com> wrote:
> On Nov 8, 6:39*am, "++imanshu" <himanshu.g...@gmail.com> 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 * * *=> 'random.ran...@gmail.com',
> > * * * * * * From * *=> 'ran...@yahoo.com',
> > * * * * * * 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

Uri Guttman 11-09-2009 06:12 PM

Re: connect to localhost failed error with Mail::Sendmail on Windows
 
>>>>> "+" == ++imanshu <himanshu.garg@gmail.com> 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 ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------

Eric Pozharski 11-10-2009 09:39 AM

Re: connect to localhost failed error with Mail::Sendmail on Windows
 
On 2009-11-09, Uri Guttman <uri@StemSystems.com> wrote:
>>>>>> "+" == ++imanshu <himanshu.garg@gmail.com> 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

Peter J. Holzer 11-10-2009 08:49 PM

Re: connect to localhost failed error with Mail::Sendmail on Windows
 
On 2009-11-09 09:45, ++imanshu <himanshu.garg@gmail.com> wrote:
> On Nov 8, 11:03*pm, smallpond <smallp...@juno.com> 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

Steve C 11-10-2009 09:04 PM

Re: connect to localhost failed error with Mail::Sendmail on Windows
 
Peter J. Holzer wrote:
> On 2009-11-09 09:45, ++imanshu <himanshu.garg@gmail.com> wrote:
>> On Nov 8, 11:03 pm, smallpond <smallp...@juno.com> 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.



Peter J. Holzer 11-10-2009 09:49 PM

Re: connect to localhost failed error with Mail::Sendmail on Windows
 
On 2009-11-10 21:04, Steve C <smallpond@juno.com> wrote:
> Peter J. Holzer wrote:
>> On 2009-11-09 09:45, ++imanshu <himanshu.garg@gmail.com> wrote:
>>> On Nov 8, 11:03 pm, smallpond <smallp...@juno.com> 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

++imanshu 11-11-2009 09:42 AM

Re: connect to localhost failed error with Mail::Sendmail on Windows
 
On Nov 11, 4:14*am, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth "Peter J. Holzer" <hjp-usen...@hjp.at>:
>
>
>
> > On 2009-11-09 09:45, ++imanshu <himanshu.g...@gmail.com> wrote:
> > > On Nov 8, 11:03*pm, smallpond <smallp...@juno.com> 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


All times are GMT. The time now is 02:26 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.