I am trying to send email from a Java/Spring software. I'm using JavaMailSender of spring framework. How can I configure local machine as JavaMailSender's smtp host? I can send email via the following command:
echo “test123” | mailx -s “test mail” emailaddress@email.com
However, how can I write my mail.properties to support the command above?
This is my javaMailSender bean:
<bean id="javaMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="${mail.smtp.host}" />
<property name="port" value="${mail.smtp.port}" />
<property name="defaultEncoding" value="${mail.defaultEncoding}" />
<property name="username" value="${mail.username}" />
<property name="password" value="${mail.password}" />
<property name="javaMailProperties">
<props>
<prop key="mail.debug">${mail.debug}</prop>
<prop key="mail.smtp.auth">${mail.smtp.auth}</prop>
<prop key="mail.smtp.starttls.enable" >${mail.smtp.starttls.enable}</prop>
</props>
</property>
</bean>
This is mail.properties file:
mail.debug = true
mail.defaultEncoding = UTF-8
mail.smtp.host = localhost
mail.smtp.port = 25
mail.username =
mail.password =
mail.smtp.starttls.enable = false
mail.smtp.auth = false
Aucun commentaire:
Enregistrer un commentaire