title: How to setup smtp server without authentication in java
body: <p>Initially i was using 'smtp.gmail.com' as smtp server for sending mails using javamail api. But now i have to change smtp server and use our client smtp server.
  The client smtp server let say is '143.12.12.1' and its without authentication.</p>
  
  <p>So, can anybody tell me what configuration i need to do ?Do i need to ask my client for the sender email which is created in their domain(Domain mean smtp server).</p>
  
  <p>Currently , i am using gmail id as sender id and smtp server is of client '143.12.12.1'.</p>
  
  <p>I have used following smtp configuration in my code:-</p>
  
  smtp.config file configurations
  
  <pre><code>#Email Configuration
  host = 143.12.12.1
  port = 25
  isAuth = false
  startTLS = true
  startSSL= false
  socketFactory = javax.net.ssl.SSLSocketFactory
  isFallback = false
  isDebug = true
  emailUser =abc@gmail.com
  password = abc
  </code></pre>
  
  <h3>ApplicationContext.xml configuration</h3>
  
  <pre><code>&lt;bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"&gt;
          &lt;property name="host" value="${host}"/&gt;
          &lt;property name="port" value="${port}"/&gt;
          &lt;property name="session" ref="mailSession"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="mailSession" class="javax.mail.Session" factory-method="getInstance"&gt;
          &lt;constructor-arg&gt;
              &lt;props&gt;
                  &lt;prop key="mail.smtp.auth"&gt;${isAuth}&lt;/prop&gt;
                  &lt;prop key="mail.smtp.starttls.enable"&gt;${startTLS}&lt;/prop&gt;
                  &lt;prop key="mail.smtp.ssl.enable"&gt;${startSSL}&lt;/prop&gt;
                  &lt;prop key="mail.smtp.socketFactory.port"&gt;${port}&lt;/prop&gt;
                  &lt;prop key="mail.smtp.socketFactory.class"&gt;${socketFactory}&lt;/prop&gt;
                  &lt;prop key="mail.smtp.socketFactory.fallback"&gt;${isFallback}&lt;/prop&gt;
                  &lt;prop key="mail.smtp.debug"&gt;${isDebug}&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/constructor-arg&gt;
          &lt;constructor-arg ref="smtpAuthenticator" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="smtpAuthenticator" class="com.ericsson.obhs.util.SmtpAuthenticator"&gt;
          &lt;constructor-arg value="${emailUser}" /&gt;
          &lt;constructor-arg value="${password}" /&gt;
      &lt;/bean
  </code></pre>
  
  <p>></p>
  
  <p>Each time i am trying to send mail, i am getting following errror :-</p>
  
  <p><strong><em>org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Exception reading response;
    nested exception is:
      javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?. Failed messages: javax.mail.MessagingException: Exception reading response;
    nested exception is:
      javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?; message exception details (1) are:</em></strong></p>