Exception reading response

I am trying to send a mail using java but i keep reciving the following erro

java.net.SocketException: Connection reset

javax.mail.MessagingException: Exception reading response;

here is my code

publicvoid sendMail(String from, String to, String cc, String bcc, String subject, String body)

{

Properties props =new Properties();

props.setProperty("mail.transport.protocol","smtp");

props.put("mail.smtp.host", SMTP_HOST_NAME);

props.put("mail.smtp.auth","true");

props.put("mail.smtp.port","465");

Authenticator auth =new SMTPAuthenticator();

Session mailSession = Session.getDefaultInstance(props, auth);

mailSession.setDebug(true);

Transport transport;

try

{

transport = mailSession.getTransport();

MimeMessage message =new MimeMessage(mailSession);

message.setSubject(subject);

message.setText(body);

message.addRecipient(Message.RecipientType.TO,

new InternetAddress(to));

if(!cc.equals(""))

{

message.addRecipient(Message.RecipientType.CC,

new InternetAddress(cc));

}

if(!bcc.equals(""))

{

message.addRecipient(Message.RecipientType.BCC,

new InternetAddress(bcc));

}

transport.connect();

transport.sendMessage(message,

message.getRecipients(Message.RecipientType.TO));

transport.close();

}

catch (NoSuchProviderException e)

{

JOptionPane.showMessageDialog(null, e.getMessage());

}

catch (MessagingException e)

{

JOptionPane.showMessageDialog(null, e.getMessage());

e.printStackTrace();

}

}

privateclass SMTPAuthenticatorextends javax.mail.Authenticator

{

public PasswordAuthentication getPasswordAuthentication()

{

String username = SMTP_AUTH_USER;

String password = SMTP_AUTH_PWD;

returnnew PasswordAuthentication(username, password);

}

}

privatestaticfinal String SMTP_HOST_NAME ="smtp.gmail.com";

I research online with no success

This code is mainly chunck of code i found online

So if anybody can tell me why i keep having that exception and what to do to get rid of it

tx

for smt

[3713 byte] By [lildavesflavaa] at [2007-11-27 7:06:28]
# 1

I answered this same question you sent to javamail@sun.com. I said...

Most likely you have a firewall or something like that that's

preventing you from connecting. Looking at the protocol trace

from your application (see the JavaMail FAQ) might provide more

information, but I doubt it.

You might also try using the msgsend.java demo program as described

in the FAQ to see if that works when using gmail. That will determine

whether there's a problem in your code or whether the problem is

elsewhere. I suspect the latter.

bshannona at 2007-7-12 18:57:46 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...