Search code examples
springjakarta-mailapplicationcontext

Log JavaMailSenderImpl


i use Spring to send email in my application. I want to log the imap server operation, when i send emails. I try to implement log in my applicationContext.xml as follow:

<bean id="JavaMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
    <property name="host" value="${smtpHost}" />
    <property name="port" value="${smtpPort}" />
    <property name="username" value="${userName}" />
    <property name="password" value="${password}" />
    <property name="session" ref="mailSession" />
    <props>
        <prop key="mail.debug">true</prop>
    </props>
</bean>

but doesn't works.Any suggest?

Thanks


Solution

  • You're missing the outer property.

    ...
    <property name="session" ref="mailSession">
    <property name="javaMailProperties">
        <props>
            <prop key="mail.debug">true</prop>
        </props>
    </property>
    ...