sending an email in java: (help a Beginner !)


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: sending an email in java: (help a Beginner !)

Hybrid View

  1. #1
    Join Date
    Aug 2005
    Posts
    8

    sending an email in java: (help a Beginner !)

    hi,
    i am new to java mail and trying to send a test mail and here's my code
    Properties props = new Properties();
    props.put("mail.host"," smtp ");

    Session mail = Session.getInstance(props,null);
    mail.setDebug(true);
    final Message msg = new MimeMessage(mail);

    Address to = new InternetAddress("to");
    Address from = new InternetAddress("from");


    msg.setFrom(from);
    msg.setRecipient(Message.RecipientType.TO,to);
    msg.setSubject("Java TEST ");
    Transport.send(msg);

    (with the assumption that i have correct details of the server and to and from addresses)
    but i get the following exception :

    javax.mail.SendFailedException: Sending failed;
    nested exception is:
    class javax.mail.MessagingException: Could not connect to SMTP host: smtp.host, port: 25;
    nested exception is:
    java.net.NoRouteToHostException: No route to host: connect


    (oh, and i also have the try and catch thing for the code)
    can u help?
    thx

  2. #2
    Join Date
    Aug 2004
    Posts
    46
    You have to use the name of an actual SMTP server as your mail host. Replace "smtp" with the name of an available SMTP server.

    JavaMail quick start
    jGuru: Fundamentals of the JavaMail API
    JavaMail FAQ
    Send email with JavaMail

  3. #3
    Join Date
    Aug 2005
    Posts
    8
    as i said, i do have the actual names, i just didn't want to post it.
    besides, the exception refers to something else not "server not found"

  4. #4
    Join Date
    Aug 2005
    Posts
    8
    the smtp server is :smtp.tiscali.co.uk

  5. #5
    Join Date
    Aug 2004
    Posts
    46
    Are you able to "see" that server from where you're running your app? Have you tried telnetting to port 25 on smtp.tiscali.co.uk?

Similar Threads

  1. Java vs. .Net. A questionnaire
    By Basil in forum .NET
    Replies: 1
    Last Post: 05-13-2005, 07:46 AM
  2. Sending an email not working?
    By geeta in forum .NET
    Replies: 2
    Last Post: 09-27-2001, 10:09 AM
  3. ALERT XP COULD DISABLE JAVA IN WEB BROWSERS AND EMAIL
    By Debbie Locker in forum Talk to the Editors
    Replies: 8
    Last Post: 07-24-2001, 08:50 PM
  4. Replies: 0
    Last Post: 07-18-2001, 09:47 AM
  5. Re: VB vs. Visual Age for Java
    By JJ in forum Enterprise
    Replies: 1
    Last Post: 07-06-2000, 05:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center