我想使用 spring mvc 通过 zohomail 发送电子邮件 zoho mail 发送电子邮件的此配置是否正确
I want to send email through zohomail using spring mvc Is this configuration correct for zoho mail to send an email
这是我通过 zohomail 发送电子邮件的 bean 配置
<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>
当我运行我的程序时,我遇到了以下错误
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 >
在您的 bean 中提及 bean id
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
而不是使用
<prop key="mail.smtp.starttls.enable">true</prop>
变为
<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>`
确保您的发件人地址也列在发件人列表中。
这是我通过 zohomail 发送电子邮件的 bean 配置
<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>
当我运行我的程序时,我遇到了以下错误
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 >
在您的 bean 中提及 bean id
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
而不是使用
<prop key="mail.smtp.starttls.enable">true</prop>
变为
<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>`
确保您的发件人地址也列在发件人列表中。