Spring - nginx中的邮件发件人

时间:2017-06-30 18:27:03

标签: spring email spring-mvc tomcat nginx

在我的spring mvc web应用程序中,我通过org.springframework.mail.MailSender发送电子邮件。虽然我的应用程序部署在tomcat上并通过nginx建立连接,但它在localhost上运行良好。

我认为问题在于nginx可能会阻止587端口。

mailSender的配置:

    A = tf.constant(np.random.randn(1000000))
    # B has to be a variable so we can assign to it
    B = tf.Variable(np.random.randn(1000000))

    # Add the assign and addition operators to the graph
    assign_to_B_op = B.assign(tf.add(A, B)) 

    init = tf.global_variables_initializer()
    with tf.Session() as sess:
        # To ensure we don't add new ops to the Graph by mistake.
        sess.graph.finalize()
        sess.run(init)
        for i in range(100):
            sess.run(assign_to_B_op)
            print(B.eval())

我的nginx confinguration:

<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
    <property name="host" value="myhost" />
    <property name="port" value="587" />
    <property name="username" value="info@myhost"/>
    <property name="password" value="mypsw"/>
    <property name="javaMailProperties">
        <props>
            <prop key="mail.smtp.auth">true</prop>
            <prop key="mail.smtp.starttls.enable">true</prop>
            <prop key="mail.smtp.ssl.trust">myhost</prop>
        </props>
    </property>
</bean>

这是我在尝试发送电子邮件时遇到的错误:

enter image description here

互联网并没有对这种配置说多少,所以如果你帮助我,我会非常高兴。

1 个答案:

答案 0 :(得分:0)

好的,所以我找到了答案。问题是我正在使用谷歌云,它阻止了587端口。

https://cloud.google.com/compute/docs/tutorials/sending-mail/