Can u check it why it gives error ?
This is my code.
why its not running even if i changed domain.
it gives error : whether adress is not valid or connection refused.
whats the problem ....
please help me
import java.io.*;
import java.net.InetAddress;
import java.util.Properties;
import java.util.Date;
import javax.mail.*;
import javax.mail.internet.*;
public class SendMail
{
public static void main(String[] argv) throws Exception
{
String host = "mail.aditechinfosys.com";
String from = "dhiren@aditechinfosys.com";
String to = " pradip5prince@yahoo.com";
try {
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", host);
props.put("mail.smtp.starttls.enable", "true");
//props.put("mail.smtp.auth","true");
// Get session
Authenticator auth = new MyAuthenticator();
Session session = Session.getDefaultInstance(props, null);
// Define message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
message.setSubject("Hello JavaMail");
message.setText("Welcome to JavaMail, by ghanshyam");
// Send message
//com.sun.mail.smtp.SMTPSSLTransport.send(message);
Transport.send(message);
}catch(Exception e) { System.out.println(e); }
System.out.println("Sent successfully !");
}
}
class MyAuthenticator extends Authenticator
{
MyAuthenticator()
{
super();
}
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication("dhiren", "pw");
}
}

