• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Java Mail Authentication

 
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While I was goggling I got the below link and that says "Username and password is generally not needed to send e-mail although your ISP may still require it to prevent spam from going through its systems."

http://www.vipan.com/htdocs/javamail.html

While I was trying without username and password am getting below exception. Please assist me how to send mail with out username and password

java.net.ConnectException: Connection timed out (errno:238)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1391)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
at javax.mail.Service.connect(Service.java:288)
at javax.mail.Service.connect(Service.java:169)
at javax.mail.Service.connect(Service.java:118)
at com.iflex.pdfmailutilities.mail.EmailSender.sendEmail(EmailSender.java:140)
at com.iflex.pdfmailutilities.mail.EmailSender.sendMail(EmailSender.java:179)
at com.iflex.pdfmailutilities.mail.EmailSender.main(EmailSender.java:164)
Caused by: java.net.ConnectException: Connection timed out (errno:238)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:462)
at java.net.Socket.connect(Socket.java:412)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

"Username and password is generally not needed to send e-mail although your ISP may still require it to prevent spam from going through its systems."


That was true in the days of dial-up, where the ISP's mail server knew that the client was an authenticated user. These days -with connections made over TCP/IP from potentially anywhere- authentication is almost always required.

But the error message sounds more like a general connection problem than something related to authentictaion. Can you telnet to port 25 of the SMTP server?
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got this code using the link earlier I possted. But this never used userid and password. Is there any other way to connect to SMTP with out userid and password

 
Ulf Dittmer
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Times have changed; you need to get used to using authentication with SMTP. The JavaMail tutorial linked from the JavaRanch JEE FAQ has code samples for that.
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to identify whether the STMP server requires authentication or not. I heard some open SMTP servers are there and they dont require any user id and password for sending email.
 
Ulf Dittmer
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No reputable ISP or hosting company runs open SMTP relays any more these day. They'd be blacklisted everywhere fast.

The error message you get when trying to connect to an SMTP without authentication will indicate that it is an authentication problem; so that's a clue :-)
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But when I tried with the same program with authentication I mean simply pass the user id and password to connect and its working fine. If i tried to connect directly without userid and password am getting this below exception. Don't know wats happening

java.net.ConnectException: Connection timed out (errno:238)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1391)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
at javax.mail.Service.connect(Service.java:288)
at javax.mail.Service.connect(Service.java:169)
at javax.mail.Service.connect(Service.java:118)
at com.iflex.pdfmailutilities.mail.EmailSender.sendEmail(EmailSender.java:140)
at com.iflex.pdfmailutilities.mail.EmailSender.sendMail(EmailSender.java:179)
at com.iflex.pdfmailutilities.mail.EmailSender.main(EmailSender.java:164)
Caused by: java.net.ConnectException: Connection timed out (errno:238)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:462)
at java.net.Socket.connect(Socket.java:412)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)
 
What's a year in metric? Do you know this metric stuff tiny ad?
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic