This content has been marked as final. Show 13 replies
If you're failing to connect, I doubt that it's sending out the messages,
but examining the protocol trace will show you what's really going on.
It seems likely that your mail server has decided that you're spamming
and so is refusing to let you send any more messages. I'm not sure why
restarting the app server would fix it unless it's just because it stops your
program from running for long enough that the server resets its state and
is willing to let you send again.
I am not closing connection in finally block,
I am closing it for each connect
Transport transport = session.getTransport("smtp");
transport.connect(host, username, password);
transport.send() ; // i m changing to this now -> transport.sendMessage(message, message.getAllRecipients());
Edited by: 928073 on Apr 17, 2012 5:09 AM
session debug output is showing me everything till QUIT command ,
also I am receiving the email.
As a return string its giving me "Could not connect to smtp host:< ip >,port : 25,response :421" message...
Am I missing something?
I do have old version of mail.jar(1.3.1) ,I tried finding defect but there is no defect as such in 1.3.1.
yes.it should be be props.put("mail.smtp.port",25);
but not props.put("mail.smtp.port","25");
I put 25 number as string which is wrong. (http://javamail.kenai.com/nonav/javadocs/com/sun/mail/smtp/package-summary.html)
I am making port configurable ,in case we change in future.So I am setting this property even if i is already set as 25 in api.
My question was putting number 25 as string overide orginal default property set by mail api??
Edited by: 928073 on Apr 18, 2012 1:13 PM
Edited by: 928073 on Apr 18, 2012 1:14 PM
Edited by: 928073 on Apr 18, 2012 1:20 PM
You didn't read carefully. There javadocs you refer to say:
Yes, setting the property overrides the built-in default.
The SMTP protocol provider supports the following properties, which may be set in the JavaMail Session object. The properties are always set as strings; the Type column describes how the string is interpreted. For example, use props.put("mail.smtp.port", "888"); to set the mail.smtp.port property, which is of type int.