Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Servlet sendmail

Status
Not open for further replies.

GIGN

Programmer
Oct 6, 2000
1,082
NZ
So I have my servlets running sweetly - all I require is how to go about mailing the results - how is this generally done?

Do I have to use Javamail? ;-)
b2 - benbiddington@surf4nix.com
 
Yep, I think my only problem is getting an Authenticator object - are there any subclasses already, or do I need to create one?
b2 - benbiddington@surf4nix.com
 
Hi,

You will have to subclass the Authenticator object yourself as there are no subclass included in the JavaMail package. Remember to include the method getPasswordAuthentication() as well :)

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Yes I have done this, the thing is, though it is called an abstract class right, it has no abstract methods - so why have they called it abstract? To force subclassing yes, but I thought it had to have atleast one abstract method? So my question is really - is abstract an optional modifier?

My next step is to try sending mail from a Servlet. So do you think I can try it without an Authenticator, can I just access my smtp server from a remote site like that? Or is this where I need to use passwords? Also, do you ever need an Authenticator to access an smtp server?



I am running my servlets locally.


b2 - benbiddington@surf4nix.com
 
Hi,

Seriously speaking, I haven't done any abstract classes before besides on RMI so I am unable to comment on that.

From what I know, there is no need to use the Authenticator at all. I used to be able to send an email without using the Authenticator class. I did it in a lab, which was connected to the server as a whole Network. However I did encounter some problems when I tried embeding it into a servlet or applet (It happened sometime ago so I forgot which it was)

Good luck,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
I think you're right - it is strange how no password is required when accessing an smtp server? But in order to recieve, you do.

Does this imply that I could choose any smtp server I like to send mail thru - or is this simply because I am logging in to my ISP to access the smtp, and it implicitly knows who I am?

I think I'll try it with some other server, and see what happens ;-) P.S. I guess abstract is an optional modifier.
b2 - benbiddington@surf4nix.com
 
Hi,

I have never tried receiving an mail using JavaMail before so I am not sure whether there is a need to authenticate yourself.

I am also not too sure on how the retrieving and sending of mails work in JavaMail so all I can say is you will have to keep trying :p

Good Luck,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Here's a weird thing you may be able to explain to me. I have this servlet which sends mail right, and thru the code for debugging purposes I have placed markers.

After an important action is performed in the code, I put a call like this:

errorMessages = errorMessages.concat("Address O.K.");

which just helps me debug. Well a weird thing is happening, where by - if I go back to the form submission page, and enter another message - then the string comes back longer than before - so it has remembered the concat() I did last time? I guess this is something to do with session timeouts?
But even when I close the browser, then go back to it - the string remains at it's last value?

Another aside - I create an InternetAddress with the input string - but it will not throw an exception, as hard as I try - why is that? ;-)
b2 - benbiddington@surf4nix.com
 
Also, I am running my servlets on JRun (Allaire). It seems that this is one of those which does not destroy Servlets until they are shutdown - hence my problems with data persistence, this has benefits though I am sure!

Now I find I set up my mesage to send, from a web page on my personal server - click send, and it works perfectly - unless I stop it connecting to the internet to send it.

If I do this I get a MessagingException - to be expected surely, yes, but then every time I try to re-send after that, no logging on even gets attempted - iy goes straight to exception? this is weird.
b2 - benbiddington@surf4nix.com
 
"I think you're right - it is strange how no password is required when accessing an smtp server? But in order to recieve, you do."

This is because when you send, the server just checks your account name against the list of authorized users and if it's there, sends it. However, more and more servers are requiring passwords to send, to prevent spammers from guessing an account name and using the email service for their own ends.

To receive, well, anyone who's ever received an email from you probably knows your account name (it's usually the same as your email addy). So obviously, you need to check the password to prevent people reading email they aren't supposed to.

Rose/Miros
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top