////
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
////

[#smtppickupdirappender.adoc]
= SmtpPickupDirAppender

The `SmtpPickupDirAppender` is configured similarly to the xref:./smtpappender.adoc[].
The only difference is that rather than specify a SmtpHost parameter a `PickupDir` must be specified.

Because this appender writes the emails to disk and leaves their delivery to another process, it uses no SMTP client at all.
It is therefore unaffected by the deprecation of `System.Net.Mail.SmtpClient`, and remains a good option when you cannot take on the MailKit dependency that the recommended xref:./smtpappender.adoc#mailkit-smtpappender[MailKit based `SmtpAppender`] requires.

The `PickupDir` parameter is a path that must exist and the code executing the appender must have permission to create new files and write to them in this directory.
The path is relative to the application's base directory (AppDomain.BaseDirectory).

The following example shows how to configure the SmtpPickupDirAppender to deliver log events via SMTP email.
The `To`, `From`, `Subject` and `PickupDir` are required parameters.
This example shows how to deliver only significant events.

A LevelEvaluator is specified with a threshold of WARN.
This means that an email will be sent for each WARN or higher level message that is logged.

Each email will also contain up to 512 (BufferSize) previous messages of any level to provide context.

Messages not sent will be discarded.

[source,xml]
----
<appender name="SmtpPickupDirAppender" type="log4net.Appender.SmtpPickupDirAppender">
  <to value="to@example.com" />
  <from value="from@example.com" />
  <subject value="test logging message" />
  <pickupDir value="C:\SmtpPickup" />
  <bufferSize value="512" />
  <lossy value="true" />
  <evaluator type="log4net.Core.LevelEvaluator">
    <threshold value="WARN"/>
  </evaluator>
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%newline%date [%thread] %-5level %logger - %message%newline%newline" />
  </layout>
</appender>
----