I'm confused and stuck in my project.
I want to send email via SMTP JAVA to an overseas email address, but I'm getting a timeout message.
I don't know why.
My configuration xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="smtp.gmail.com" />
<property name="port" value="25" />
<property name="username" value="[email protected]" />
<property name="password" value="password" />
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.starttls.enable">true</prop>
</props>
</property>
</bean>
<bean id="emailService" class="com.dwidasa.iacssweb.service.feature.EmailService">
<property name="mailSender" ref="mailSender" />
<property name="simpleMailMessage" ref="customeMailMessage" />
</bean>
<bean id="customeMailMessage"
class="org.springframework.mail.SimpleMailMessage">
<property name="subject" value="RESET PASSWORD" />
<property name="text">
<value>
<![CDATA[
Dear %s,
%s
]]>
</value>
</property>
</bean>
</beans>
Please help me, there is no error, just a connection timeout. I'm confused because when I tested on a local server, it succeeded.
Error:
Caused by:
org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: smtp.dwidasa.com, port: 587; nested exception is: java.net.ConnectException: Connection timed out (Connection timed out). Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: smtp.dwidasa.com, port: 587; nested exception is: java.net.ConnectException: Connection timed out (Connection timed out); message exception details (1) are: