如何在log4j.xml中隐藏来自接收者的电子邮件地址?

时间:2016-11-22 09:14:42

标签: java spring log4j

我想向用户发送一封电子邮件,其中用户无法查看实际的地址。这是我的log4j.xml。我需要将“username@gmail.com”替换为“no-reply@gmail.com”。

 <appender name="mailAppender" class="org.apache.log4j.net.SMTPAppender">
    <param name="BufferSize" value="512" />
    <param name="SMTPHost" value="smtp.gmail.com" /> 
    <param name="SMTPPort" value="465" />
    <param name="SMTPUsername" value="username@gmail.com" />
    <param name="SMTPPassword" value="password" />
    <param name="SMTPProtocol" value="smtpprotocol" />  
    <param name="From" value="username@gmail.com" />
    <!-- <param name="From" value="no-reply@gmail.com" /> -->
    <param name="To" value="toaddress@gmail.com" />
    <param name="Subject" value="Welcome" />
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="[%d{ISO8601}]%n%n%-5p%n%n%c%n%n%m%n%n" />
    </layout>
    <filter class="org.apache.log4j.varia.LevelRangeFilter">
        <param name="LevelMin" value="error" />
        <param name="LevelMax" value="fatal" />
    </filter>
</appender>

<root>
    <priority value="warn" />
    <appender-ref ref="mailAppender" />
</root>

1 个答案:

答案 0 :(得分:0)