JAVA Mail settings for SMTP Print

  • 249

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 inexpensive 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);

Connecting remotely using Spring Boot

    host: jpcloud.server.hostname
    port: 587
    password: email_password
    properties.mail.smtp.auth: true
    properties.mail.smtp.starttls.enable: true 


javax.mail.SendFailedException: Invalid Addresses;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 553 sorry, your envelope sender has been denied (#5.7.1)
    at com.sun.mail.smtp.SMTPTransport.rcptTo(
    at com.sun.mail.smtp.SMTPTransport.sendMessage(

The above error is likely due to missing 'from' email address.

Was this answer helpful?

« Back