quote

Visualizzazione post con etichetta gmail. Mostra tutti i post
Visualizzazione post con etichetta gmail. Mostra tutti i post

martedì, febbraio 19, 2008

spring mail configuration using gmail as smtp server

If you are going to use gmail as smtp server in your spring configuration file remember to add the property mail.smtp.starttls.enable and set it to true.
Here the configuration of mailSender used in jugevents .

<!-- start mail section -->
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<!-- here your smtp server -->
<property name="host"><value>smtp.gmail.com</value></property>
<!-- Parameters for SMTP AUTH -->
<property name="username"><value>yourUsername</value></property>
<property name="password"><value>yourPassword</value></property>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
<!-- used by gmail smtp server -->
<prop key="mail.smtp.starttls.enable">true</prop>
</props>
</property>
</bean>

Fail doing it you will face into the following exception

org.springframework.mail.MailSendException; nested exception details (1) are: Failed message 1: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first z37sm13522675ikz.1 at

Thanks to Lucio for the help.