1
votes

This is my bean configuration for sending an email through zohomail

  <bean class="org.springframework.mail.javamail.JavaMailSenderImpl">
                <property name="host" value="smtp.zoho.com" />
                <property name="port" value="587" />
                <property name="username" value="eamilId" />
                <property name="password" value="password" />
                <property name="javaMailProperties">
                    <props>
                        <prop key="mail.transport.protocol">smtp</prop>
                        <prop key="mail.smtp.auth">true</prop>
                        <prop key="mail.smtp.starttls.enable">true</prop>
                    </props>
                </property>
        </bean>

While I am running my program I am getting below error

org.springframework.mail.MailSendException: Failed to close server connection after message failures; nested exception is javax.mail.MessagingException: Can't send command to SMTP host; nested exception is: java.net.SocketException: Connection closed by remote host. Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 553 Relaying disallowed as ; message exception details (1) are: Failed message 1: com.sun.mail.smtp.SMTPSendFailedException: 553 Relaying disallowed as < Zandig@Zandig-PC >

1
Have you tried to run your progam with this configuration? what 's the result?are you getting any error/exception?Bacteria
yeah i tried,i am getting error like this org.springframework.mail.MailSendException: Failed to close server connection after message failures; nested exception is javax.mail.MessagingException: Can't send command to SMTP host; nested exception is: java.net.SocketException: Connection closed by remote host. Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 553 Relaying disallowed as <Zandig@Zandig-PC> ; message exception details (1) are: Failed message 1: com.sun.mail.smtp.SMTPSendFailedException: 553 Relaying disallowed as <Zandig@Zandig-PC>bhanu priya

1 Answers

4
votes

Mention bean id in your bean

<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">    

Instead of using

<prop key="mail.smtp.starttls.enable">true</prop>

change into

<prop key="mail.smtp.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
<prop key="mail.smtp.socketFactory.fallback">false</prop>
<prop key="mail.smtp.socketFactory.port">465</prop>
<prop key="mail.smtp.startssl.enable">true</prop>`

Ensure that your from address is also listed in sender list also.