kerzner
asked on
JavaMail - keeping session alive
When emailing using this java code,
Session session = Session.getInstance(props, new MyAuthenticator(username, password));
.... settings
tr = session.getTransport("smtp ");
tr.send(msg);
after some period of inactivity, I get this error
550-currently not permitted to relay through this server. Perhaps you have not
550-logged into the pop/imap server in the last 30 minutes or do not have SMTP
550 Authentication turned on in your email client.
I I run an email client, (i.e., Evolution) which check email every 10 minutes, my code always works. But this does not seem like a clean solution. How do I keep my session alive?
Thank you,
Mark
Session session = Session.getInstance(props,
.... settings
tr = session.getTransport("smtp
tr.send(msg);
after some period of inactivity, I get this error
550-currently not permitted to relay through this server. Perhaps you have not
550-logged into the pop/imap server in the last 30 minutes or do not have SMTP
550 Authentication turned on in your email client.
I I run an email client, (i.e., Evolution) which check email every 10 minutes, my code always works. But this does not seem like a clean solution. How do I keep my session alive?
Thank you,
Mark
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
But I always get new session!.
I mean, I am not using this old connection; every time I need to send an email, I execute this code above. So it is always a new connection, or should be.
Nevertheless, every mail client beats me. I had this error in windows, and now I am having it in Linux. What does mail client to different from me?
I mean, I am not using this old connection; every time I need to send an email, I execute this code above. So it is always a new connection, or should be.
Nevertheless, every mail client beats me. I had this error in windows, and now I am having it in Linux. What does mail client to different from me?
ASKER
I saw a similar question on the Ruby forum and the solution was
Net::SMTP.start('localhost ', 25, 'localhost.localdomain', 'mickey', 'cheese', :login) do |smtp|
how do you do the same thing in java? In other words, how do you login rather than grab an already existing session?
Net::SMTP.start('localhost
how do you do the same thing in java? In other words, how do you login rather than grab an already existing session?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
:-)
if (needNewSession) {
getNewSession();
}
// Carry on with sending