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