JAVA Mail settings for SMTP

The mail server most likely resides on the same server that hosts your site so you will need to use 'localhost' as your SMTP server or instead of localhost use the server hostname. All our cheap Java hosting plans have a mail server running on localhost. Session session = Session.getInstance( properties,new SMTPAuthenticator(properties)); The properties object (Properties class) should have similar properties as the example below. For more detailed information, please refer to javamail docs:

The SMPTAuthenticator is as follows:
private class SMTPAuthenticator extends javax.mail.Authenticator {
  private String user;
  private String pass;
SMTPAuthenticator (Properties properties){
  this.user = properties.getProperty("");
  this.pass = properties.getProperty("password");
public PasswordAuthentication getPasswordAuthentication() {
  return new PasswordAuthentication(this.user,this.pass);
  • 248 Users Found This Useful
Was this answer helpful?

Related Articles

Spring Framework

Need to develop Plain Old JAVA Objects? Want to have fun developing your application? Then we...

Subdomain Handling Tutorial

This tutorial explains how you can host subdomains with JavaPipe's Tomcat hosting. This is...

Pointer Domain Handling Tutorial

This tutorial explains how you can host pointer domains with a Java web hosting package from...

Choosing between JBoss7's Standalone or Domain features.

JBoss 7 introduced new feature called managed domains. Basically this is a multi-server...

How do I restart my tomcat?

However, if you have a private Tomcat instance with a Java host like us, then you have the...