wood burning stoves 2.0*
The moose likes Other JSE/JEE APIs and the fly likes Couldn't send mail from gmail to yahoo.com Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Couldn Watch "Couldn New topic
Author

Couldn't send mail from gmail to yahoo.com

Rajasekhar Karanam
Greenhorn

Joined: Sep 18, 2011
Posts: 15

Rajasekhar Karanam
Greenhorn

Joined: Sep 18, 2011
Posts: 15

Here is the error message:
Exception in thread "main" javax.mail.AuthenticationFailedException: failed to connect, no password specified?
at javax.mail.Service.connect(Service.java:329)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at GoogleToYahoo.main(GoogleToYahoo.java:39)
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10172
    
    8

Instead of java.net.PasswordAuthentication you should be using javax.mail.PasswordAuthentication

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

I'm surprised this code even compiles. Line 29 should have given a compiler error due to incompatible return types - the only thing in commin between java.net.PasswordAuthentication and javax.mail.PasswordAuthentication is a) the name, and b) the purpose, although for different systems.

Edit: ah, now I see. The method in that piece of code isn't called getPasswordAuthentication but getPasswordAuthenticaton - missing the i. Adding an @Override annotation would have given that away directly.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rajasekhar Karanam
Greenhorn

Joined: Sep 18, 2011
Posts: 15

Thanks guys!

I have used javax.mail.PasswordAuthentication and edited 3 mistakes
Line 12 smtp.gmail.com
Line 29 Authentication is corrected
Line 30 Password must be string!

And Now Its working! Thanks a lot!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Couldn't send mail from gmail to yahoo.com
 
Similar Threads
java mail
how to send a mail to yahoo user
AuthenticatedFailedException is thrown javamail
How to send mail form java application
sending email