I m having problem with sending mail with POP3 server, the funny thing is when I try to run the same block of code via public static void main() it runs fine, but when it is ran through a batch flow throws error @
transport.connect(hostName, userName, password);
saying....
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "Smtp.mail.apac.microsoftonline.com", port 25, isSSL false
One more thing to notice here is even though I set POP3 port to ["mail.smtp.port", "587"] in the session properties, its using port number as 25,
and when I explicitly ask it to connect via port over 587
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "Smtp.mail.apac.microsoftonline.com", port 587, isSSL false
220 smtp.mail.apac.microsoftonline.com Microsoft ESMTP MAIL Service ready at Tue, 14 Jun 2011 03:07:08 -0700
DEBUG SMTP: connected to host "Smtp.mail.apac.microsoftonline.com", port: 587
Hey Ulf, sorry for confusion indeed mail is sent over SMTP protocol, and have used SMTP for sending mail... and if you had noticed my post i m using Smtp.mail.apac.microsoftonline.com host as well.
I apologize in heat of the situation and deadline my Post header was misleading...
but the issue is still open please provide your insight on the problem.
And gonna change the Post Subject/header so others wont get mislead.
Thanks
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35443
9
posted
0
How are you providing the authentication details?
Mithun Pissay
Greenhorn
Joined: Dec 12, 2009
Posts: 6
posted
0
Hi Ulf, FYI
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.smtp.host", "Smtp.mail.apac.microsoftonline.com");
props.setProperty("mail.smtp.port", "587");
props.setProperty("mail.smtp.auth","true");
props.put("mail.smtp.starttls.enable","true");
...
Getting java mail Session with passing authenticator as null later part in the code SMTPTransport would connect and authenticate along with userEmailId and password.
Further, for your information, after you brought up authentication perspective, i tried getting session with passing an authenticator object with userEmailId and password set in the auth object, And the result was same with above test case (referring to initial post) execution.
Mithun Pissay
Greenhorn
Joined: Dec 12, 2009
Posts: 6
posted
0
Hi guys, thanks for your time and brain stroming over my posted issue,
I found out the issue was with not using System properties (i.e System.getProperties() ), even though I was setting designated port (587) into java.util.Properties it was taking default port 25 for sending mail via SMTP as it was reading from the system properties for getting port and it had not been set while getting mail Session project.
But one thing is still bugging me is why with all the session properties set into java.util.Properties object for getting mail Session was working when called independently and not working when the batch flow took over the call to send mail,
and let me tell you i was not using properties object got from System.getProperties() call before any where. is it the API designed so to read from System.getProperties() properties ? I am using standard mail.jar i.e java extended API
If any of you guys know what exactly the reason please do reply to this post.