How to send log to mail using log4j 2?

Logging to console and file is working correctly,but emails are not sending.

there are settings :

<?xml version="1.0" encoding="UTF-8"?>
<configuration status="warn" name="MyApp" packages>

 <!-- SMTP appender -->
 <smtp name="Mail" subject="Logging" to="" from="" smtphost="" smtpport="465" buffersize="100" smtpprotocol="smtps">
 <pattern>%d{dd MM yyyy HH:mm:ss,SSS} - %msg%n</pattern>

 <!-- File appender -->
 <file name="File" filename="c:/logs/app.log">
 <pattern>%d{dd MM yyyy HH:mm:ss,SSS} - %msg%n</pattern>

 <!-- Console appender -->
 <console name="STDOUT" target="SYSTEM_OUT">
 <patternlayout pattern="%m%n">


 <root level="error">
 <appenderref ref="Mail">
 <appenderref ref="File">
 <appenderref ref="STDOUT">


writes :
JavaFX Application Thread ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.SmtpAppender element for SMTP: java.lang.NoClassDefFoundError: javax/mail/MessagingException java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(

JavaFX Application Thread ERROR Null object returned for SMTP Appenders in.

if that documentation here :
June 5th 19 at 21:14
1 answer
June 5th 19 at 21:16
Obviously not enough classes for working with SMTP.
I have worked to add dependencies in Maven:

Find more questions by tags JavaLoggingLog4j