I want to send email through zohomail using spring mvc Is this configuration correct for zoho mail to send an email

回眸只為那壹抹淺笑 提交于 2019-12-11 10:23:11

问题


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:


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.



来源:https://stackoverflow.com/questions/34085695/i-want-to-send-email-through-zohomail-using-spring-mvc-is-this-configuration-cor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!