On Tue, Apr 24, 2012 at 03:59:27PM -0700, Michael Rasmussen wrote:
> On 2012-04-24 13:17, Somu wrote:
> >Ok.. Thanks for the info on gmail.
> >But is there any way to find out such information for other hosts?
> >Like I have an account at https://ems.sbi.co.in so again how do i
> >do for
> >that?
> 
> 
> You use the DNS system, usually with nslookup or dig to an mx lookup
> type.  MX stands for Mail eXchanger.
> Examples:
> $ > dig jamhome.us mx
> 
> ; <<>> DiG 9.6-ESV-R4-P1 <<>> jamhome.us mx
> ;; global options: +cmd
> ;; Got answer:
> ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17630
> ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0
> 
> ;; QUESTION SECTION:
> ;jamhome.us.                    IN      MX
> 
> ;; ANSWER SECTION:
> jamhome.us.             86400   IN      MX      20 barn.michaelsnet.us.
> jamhome.us.             86400   IN      MX      10 post.michaelsnet.us.
> 
> ;; Query time: 81 msec
> ;; SERVER: 192.168.151.40#53(192.168.151.40)
> ;; WHEN: Tue Apr 24 17:57:27 2012
> ;; MSG SIZE  rcvd: 82
> 
> 
> 
> or
> 
> $  nslookup
> >set type=mx
> >jamhome.us
> Server:         192.168.151.40
> Address:        192.168.151.40#53
> 
> Non-authoritative answer:
> jamhome.us      mail exchanger = 10 post.michaelsnet.us.
> jamhome.us      mail exchanger = 20 barn.michaelsnet.us.
> 
> 
nslookup and dig can confirm or deny the existence of MX records e.g.

 nslookup
 > set q=mx
 > example.com
 Server:         80.68.80.24
 Address:        80.68.80.24#53

 Non-authoritative answer:
 *** Can't find example.com: No answer

 Authoritative answers can be found from:
 example.com
         origin = dns1.icann.org
         mail addr = hostmaster.icann.org
         serial = 2011063451
         refresh = 7200
         retry = 3600
         expire = 1209600
         minimum = 3600

dig example.com

; <<>> DiG 9.8.1-P1 <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51388
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;example.com.                   IN      A

;; ANSWER SECTION:
example.com.            3257    IN      A       192.0.43.10

;; Query time: 0 msec
;; SERVER: 80.68.80.24#53(80.68.80.24)
;; WHEN: Thu Apr 26 14:13:44 2012
;; MSG SIZE  rcvd: 45


The original OP's problem was that his code was hanging and he didn't
understand why.  The why was clarified by Leo.  

Once he had confirmed the existence of mail servers, he would then need to use
telnet to discover the problem e.g.

telnet jamhome.us 25
Trying 69.33.100.122...
Connected to jamhome.us.
Escape character is '^]'.
220 post.michaelsnet.us ESMTP Postfix

and: 

telnet gmail.com 25
Trying 173.194.34.181...
Trying 173.194.34.182...
telnet: Unable to connect to remote host: Connection timed out

which would have shown him the standard SMTP request was timing out.

The OP's next problem is to find out what ports the mail server listens on.
Having discovered that port 25 was timing out and not giving an SMTP response
of any kind, I would at least search the web for gmail + smtp information,
which turns up these first three links 
http://www.authsmtp.com/gmail/index.html
http://support.google.com/mail/bin/answer.py?hl=en&answer=13287
http://email.about.com/od/accessinggmail/f/Gmail_SMTP_Settings.htm

A search for gmail + smtp + port produces a more interesting result and a basic
portscan on interesting ports gives :

 nmap -p 25,80,443,465,587 gmail.com

 Starting Nmap 5.21 ( http://nmap.org ) at 2012-04-26 14:24 BST
 Nmap scan report for gmail.com (173.194.34.85)
 Host is up (0.013s latency).
 Hostname gmail.com resolves to 4 IPs. Only scanned 173.194.34.85
 rDNS record for 173.194.34.85: lhr14s19-in-f21.1e100.net
 PORT    STATE    SERVICE
 25/tcp  filtered smtp
 80/tcp  open     http
 443/tcp open     https
 465/tcp filtered smtps
 587/tcp filtered submission

 Nmap done: 1 IP address (1 host up) scanned in 1.29 seconds


which starts to give some clues.  SMTP is there but it appears we cannot access
it.  There's an smtp over ssh service on port 465 and a submission service on
port 587.

A separate check of /etc/services for smtp ports e.g.
grep smtp /etc/services
smtp            25/tcp          mail
ssmtp           465/tcp         smtps           # SMTP over SSL

and the port Leo mentioned

grep 587 /etc/services
submission      587/tcp                         # Submission [RFC4409]
submission      587/udp

Also gives some clues.
See http://www.rfc-editor.org/rfc/rfc4409.txt for more info on the submission
protocol.

Ultimately the OP would accept that he needed to do some reading of the 
appropriate
manual to better understand gmail's smtp system and perhaps also work on
understanding at least the motivation of the submission protocol and how it can
be used - http://knowledge.legend.co.uk/taxonomy/term/2 might be a good read
here.

But at least he has learnt there are two other ports besides port 25 used in
messaging systems on the internet.

Regards

Lesley
> 
> 
> >On Tue, Apr 24, 2012 at 10:38 PM, Leo Susanto
> ><leosusa...@gmail.com> wrote:
> >
> >>Gmail is implementing secure SMTP, so plain SMTP won't work.
> >>
> >>use Net::SMTP::TLS;
> >>
> >>And make sure you are using these information
> >>       Host     => 'smtp.gmail.com',
> >>       Hello    => 'gmail.com',
> >>       Port     => 587,
> >>       User     => 'x...@gmail.com',
> >>
> >>
> >>On Tue, Apr 24, 2012 at 9:57 AM, Somu <som....@gmail.com> wrote:
> >>> SMTP is a Protocol, which uses standard commands to send mail.
> >>>
> >>> I want to use it. So there is already an implementation
> >>written. So I'm
> >>not
> >>> going for IO or Sockets..
> >>> I want to make it work.
> >>> Please, I need some workable parameters. Help.
> >>> And it dies, simply. Don't know what goes on beneath the
> >>surface...
> >>>
> >>>
> >>> On Tue, Apr 24, 2012 at 6:26 AM, Michael Rasmussen
> >><mich...@jamhome.us
> >>>wrote:
> >>>
> >>>> On Tue, Apr 24, 2012 at 01:54:15AM +0530, Somu wrote:
> >>>> > Hi everyone...
> >>>> > Why isn't it happeing!!??
> >>>> >
> >>>> > Just the code from Net::SMTP docs
> >>>> >
> >>>> > __________________________________________________________
> >>>> >
> >>>> > use strict;
> >>>> > use warnings;
> >>>> > use Net::SMTP;
> >>>> >
> >>>> > #these 3 lines bring the output mx.google.com
> >>>> > # my $smtp = Net::SMTP->new('smtp.gmail.com') or die $!;
> >>>> > # print $smtp->domain,"\n";
> >>>> > # $smtp->quit;
> >>>> >
> >>>> >
> >>>> >
> >>>> > #but for this...
> >>>> >     my $smtp = Net::SMTP->new('smtp.gmail.com') or die $!;
> >>>> >
> >>>> >     $smtp->mail('som....@gmail.com') or die $!;    #it dies
> >>here. No
> >>>> errors.
> >>>>
> >>>> Does it die or does it hang?
> >>>> When I tried this, modified to connect to a bogus host, the
> >>program hung
> >>>> at this point.
> >>>> Editing to use a legitmate host it ran fine.
> >>>>
> >>>> > And how are we going to know any mailhost's address???
> >>>>
> >>>> most programs/people ask the DNS system to return the mail
> >>host for any
> >>>> given domain.
> >>>>
> >>>> > Its irritating when you fail on the first step.
> >>>>
> >>>> Yes it's irritating. What is your  objective?  To learn about
> >>SMTP and
> >>>> Perl or to
> >>>> just send some mail?
> >>>>
> >>>> If "just send some mail" consider using Mail::Sender or
> >>Mail::SendEasy.
> >>>>
> >>>> --
> >>>>            Michael Rasmussen, Portland Oregon
> >>>>      Other Adventures: http://www.jamhome.us/ or
> >>http://westy.saunter.us/
> >>>> Fortune Cookie Fortune du courrier:
> >>>> > Linux is not user-friendly.
> >>>> It _is_ user-friendly.  It is not ignorant-friendly and
> >>idiot-friendly.
> >>>>                ~ Seen somewhere on the net
> >>>>
> >>>
> >>>
> >>>
> >>> --
> >>> Love,
> >>>  Somu,
> >>> http://lose.yourself.mcommunity.biz
> >>> http://fidel.castro.peperonity.com
> >>
> 
> -- 
>      Michael Rasmussen
>    http://www.jamhome.us/
> Be Appropriate && Follow Your Curiosity
> 
> -- 
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
> 
> 

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to