Reputation: 490
I am trying to send an email using Spring and GMail. However, the email is not getting sent. I'm not receiving any errors. Below is my setup:
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailS enderImpl">
<property name="host" value="smtp.gmail.com"/>
<property name="port" value="256"/>
<property name="username" value="MyUsername"/>
<property name="password" value="MyPassword"/>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.starttls.enable">true</prop>
</props>
<bean id="userDefServiceTarget"
class="com.xxx.setups.userdef.business.UserDefMgr" >
<property name="mailSender"><ref local="mailSender"/></property>
</bean>
In my UserDefMgr class :
public void postMail()
{
SimpleMailMessage message = new SimpleMailMessage() ;
message.setSentDate(new Date()) ;
message.setSubject("Test") ;
message.setText("My First email. from java") ;
message.setFrom("[email protected]") ;
mailSender.send(message) ;
}
What am I doing wrong? It's going thru the method and has all of the properties when it executes the send method.
Thanks in advance...
Upvotes: 0
Views: 104