This content has been marked as final. Show 13 replies
Are you closing the connection? in a finally block? and are you conserving them? i.e. sending as many emails as possible on the same connection?1 person found this helpful
If you're failing to connect, I doubt that it's sending out the messages,1 person found this helpful
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.
I am not closing connection in finally block,So close it in a finally block.
I do have old version of mail.jar(1.3.1)So use the current version.
Thanks..So all my connections are remain open after it throws messaging exception?
They are open unless you close them, and if your close isn't in a finally block it can be bypassed by an exception.1 person found this helpful
One last question:
I included props.put("mail.smtp.port","25");
which is wrong, as port should be integer not string.
Is this overriding orginal property? Can it do something wrong?
Properties should be set as strings; read the javadocs.
You don't need to set this property because that's the default value.
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:1 person found this helpful
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.
Sorry...n great Thanks...I am saved from this mistake !