0
votes

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.

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).

Currently , i am using gmail id as sender id and smtp server is of client '143.12.12.1'.

I have used following smtp configuration in my code:-

smtp.config file configurations
#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 [email protected]
password = abc

ApplicationContext.xml configuration

<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
        <property name="host" value="${host}"/>
        <property name="port" value="${port}"/>
        <property name="session" ref="mailSession"></property>
    </bean>

    <bean id="mailSession" class="javax.mail.Session" factory-method="getInstance">
        <constructor-arg>
            <props>
                <prop key="mail.smtp.auth">${isAuth}</prop>
                <prop key="mail.smtp.starttls.enable">${startTLS}</prop>
                <prop key="mail.smtp.ssl.enable">${startSSL}</prop>
                <prop key="mail.smtp.socketFactory.port">${port}</prop>
                <prop key="mail.smtp.socketFactory.class">${socketFactory}</prop>
                <prop key="mail.smtp.socketFactory.fallback">${isFallback}</prop>
                <prop key="mail.smtp.debug">${isDebug}</prop>
            </props>
        </constructor-arg>
        <constructor-arg ref="smtpAuthenticator" />
    </bean>

    <bean id="smtpAuthenticator" class="com.ericsson.obhs.util.SmtpAuthenticator">
        <constructor-arg value="${emailUser}" />
        <constructor-arg value="${password}" />
    </bean

>

Each time i am trying to send mail, i am getting following errror :-

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:

1

1 Answers

0
votes

Get rid of all the socket factory and port settings, you don't need them and they're causing you to connect on the wrong port. You might need to set startTLS = false depending on the requirements of your server.

You'll definitely want the "From" address to be an address known to your client mail server.