This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

excveption in mail api please help  RSS feed

Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well i have many tried to send email .But the exception arise can any body tell where i am wrong.
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class MailExample {
public static void main (String args[]) throws Exception {

// Get system properties
Properties props = System.getProperties();
// Setup mail server
// Get session
Session session = Session.getDefaultInstance(props, null);
// Define message
MimeMessage message = new MimeMessage(session);
// Set the from address
message.setFrom(new InternetAddress
// Set the to address
new InternetAddress(""));
// Set the subject
message.setSubject("Hello JavaMail");
// Set the content
message.setText("Welcome to JavaMail i got it");
// Send message
Exception in thread "main" javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: Could not connect to SMTP host: mail.yaho, port: 25;
nested exception is: Operation timed out: no further informa
at javax.mail.Transport.send0(
at javax.mail.Transport.send(
at MailExample.main(
Jawwad Ahmed
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
firstly, it is not "" but "".
secondly, even if u correct the server name, it won't work because yahoo has now restricted access to it's pop/smtp servers and one can't connect(for free) to it through mail clients.(Try accessing ur yahoo account thru outlook, it wud fail.)
Rest of the code is fine. Just change the server. Try out with's free
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator is the address of server on which http service is running . u need mail server address of yahoo server . try 2 make a class file that query a DNS server for MX record . Through this u can make a generic application which can send mail anywhere .
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!