Results 1 to 4 of 4
  1. #1
    anthrax is offline Member
    Join Date
    Feb 2009
    Posts
    57
    Rep Power
    0

    Default javax.mail.SendFailedException

    private static void fetchConfig() {
    InputStream input = null;
    try {
    //If possible, one should try to avoid hard-coding a path in this
    //manner; in a web application, one should place such a file in
    //WEB-INF, and access it using ServletContext.getResourceAsStream.
    //Another alternative is Class.getResourceAsStream.
    //This file contains the javax.mail config properties mentioned above.
    input = new FileInputStream( "C:\\Temp\\MyMailServer.txt" );
    fMailServerConfig.load( input );
    }
    catch ( IOException ex ){
    System.err.println("Cannot open and load mail server properties file.");
    }
    finally {
    try {
    if ( input != null ) input.close();
    }
    catch ( IOException ex ){
    System.err.println( "Cannot close mail server properties file." );



    here is the error:

    Cannot open and load mail server properties file.
    Cannot send email. javax.mail.SendFailedException: Sending failed;
    nested exception is:
    class javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25

    i want to make a simple email program so i find some code but i get errors.
    C:\\Temp\\MyMailServer.txt <<<==== i dont know mail server config but he mention about an "....alternative is Class.getResourceAsStream." how do i implement Class.getResourceAsStream and get rid of the above errors? tnx

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    Those errors are next to useless.
    You must print the stack trace, otherwise how on earth do you know where that exception was thrown from?

    Anyway, presuming it's your file, does it exist at the location you've given?

  3. #3
    anthrax is offline Member
    Join Date
    Feb 2009
    Posts
    57
    Rep Power
    0

    Default

    sorry its not my file and i dont know the content of MyMailServer.txt, i just found the code on the net i tried to explore it hoping i would learn something but it doesnt run since a file is missing.. im looking for a simple java program that could send email.. i think i should look more.. tnx

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    If this "C:\\Temp\\MyMailServer.txt" doesn't exist then that code will fail.

    If you're going to borrow code and try and build something from this borrowed code you really need to know the language beforehand...and be able to spot when code has been badly written.

Similar Threads

  1. problem with sending mail usin javaX.mail api
    By sandeepsai39 in forum New To Java
    Replies: 4
    Last Post: 11-25-2009, 06:37 AM
  2. javax.mail.Transport
    By sharpi03 in forum Advanced Java
    Replies: 5
    Last Post: 10-23-2009, 06:26 PM
  3. javax.mail.SendFailedException: Invalid Addresses;
    By Anju Jose in forum Advanced Java
    Replies: 2
    Last Post: 03-08-2009, 01:29 AM
  4. Replies: 2
    Last Post: 05-05-2008, 07:01 AM
  5. I can't import javax.mail
    By katie in forum New To Java
    Replies: 2
    Last Post: 08-04-2007, 06:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •