Only 49 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

not able to send mail using google smtp  RSS feed

 
Sajan Shakya
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below attached is my code and error.


ERROR:


Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: [EOF]
        at SendEmail.main(SendEmail.java:57)
Caused by: javax.mail.MessagingException: [EOF]
        at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:1481)
        at com.sun.mail.smtp.SMTPTransport.helo(SMTPTransport.java:917)
        at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:417)
        at javax.mail.Service.connect(Service.java:310)
        at javax.mail.Service.connect(Service.java:169)
        at javax.mail.Service.connect(Service.java:118)
        at javax.mail.Transport.send0(Transport.java:188)
        at javax.mail.Transport.send(Transport.java:118)
        at SendEmail.main(SendEmail.java:52)
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sajan, welcome to the Ranch!

What you posted there looks more or less like the sample code I've seen elsewhere for using Gmail to send messages. I haven't examined it in detail, though. The only problem I see is, I wouldn't expect to be able to use Gmail to send messages from some other domain (like abcd.com). I would expect the authentication to fail, for one thing.

However the error message you posted isn't quite what I would expect. It looks more like you can't make a connection to Gmail's SMTP server, maybe.
 
Sajan Shakya
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the same code is working fine for other servers, i can telnet to localport 25 as well as 587, the problem is with only one server. Thanks in advance
 
Rob Spoor
Sheriff
Posts: 20892
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Possibly it's a firewall issue. Can you have your infrastructure guys check it out?
 
Ron McLeod
Saloon Keeper
Posts: 1424
206
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just ran your code and it worked as expected.

Try adding session.setDebug(true) and compare the output against what I saw:
 
Omar abdellah
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just ran the code and it not worked as expected.
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: "myhost", port: 25;
  nested exception is:
java.net.ConnectException: Connection timed out: connect
 
Rob Spoor
Sheriff
Posts: 20892
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a machine called "myhost" that has a mail server running? Because that's not Google's SMTP server.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!