Jump to content
  • Advertisement
Sign in to follow this  
Tree Penguin

[web] JSP: sending e-mails

This topic is 4449 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i am having problems sending emails with my current ISP from a JSP page or Java. When i run a mail server at localhost i have no problem connecting to it, but when i try to connect to my ISP's server i get a javax.mail.AuthenticationFailedException. It works fine in Outlook (without encryption), with the same host, port, username and password i used here. So i guess it's just some variable i need to set or something. At the moment i am using this code:
Properties props = System.getProperties();
props.put("mail.smtp.host", "smtp.host.nl");
props.put("mail.smtp.protocol", "smtp");
props.put("mail.smtp.user","username");		// Tried username@host.nl
props.put("mail.smtp.password","password");	// Works in Outlook
props.put("mail.smtp.auth","true");		// false gives connection refused

props.put("mail.smtp.port", "25");
props.put("mail.smtp.starttls.enable","true");	// Tried false, same problem

Session session2 = Session.getInstance(props, null);

Message msg = new MimeMessage(session2);
if (from != null)
	msg.setFrom(new InternetAddress(from));
msg.setSentDate(new Date());


I tried smtps but still the same problem, and i tried every combination for these values i could think of and i always get the authentication exception (or could not connect). Also i tried: Transport transport=session2.getTransport("smtp"); ... Transport.send(msg); Instead of Transport.send(msg) but it gave me the same problems. Did i miss anything?

Share this post

Link to post
Share on other sites
Have you tried:

1. Using a network analyser to see what errors the server sends back?
2. Connecting manually using (e.g.) Telnet to see what happens then?

Normally for a web application to send mail I'd suggest that running a local MTA is essential, to queue messages for the smart host - otherwise, in the event of your smart host being down, mail will get lost.


Share this post

Link to post
Share on other sites
Have you contacted your network administrator about the correct SMTP smart host to use?

I still think that running a local MTA is the right way to go about this.


Share this post

Link to post
Share on other sites
As i said Outlook works fine, but telnet and java mail don't. And i don't really feel like being put on hold for 2 hours to ask a question they probably won't answer anyway.

Do you recommend a specific MTA?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!