title: Why I cannot send email via Log4j SMTPAppender?
body: <p>I use <code>Log4j 1.2.17</code> for loggining. I want to send error message to my email but I have some problems.
  Here is my <code>properies</code> file:   </p>
  
  <pre><code>log4j.appender.email=org.apache.log4j.net.SMTPAppender   
  log4j.appender.email.Threshold=WARN
  log4j.appender.email.SMTPHost=smtp.gmail.com
  log4j.appender.email.SMTPUsername=myGmailAddress
  log4j.appender.email.SMTPPassword=passwordToMyGmailAddress
  log4j.appender.email.From=myGmailAddress
  log4j.appender.email.To=anotherGmailAddress
  log4j.appender.email.Subject=Log of messages
  log4j.appender.email.layout=org.apache.log4j.SimpleLayout 
  </code></pre>
  
  <p>Where <code>myGmailAddress</code> and <code>passwordToMyGmailAddress</code> are my valid gmail and password. <code>anotherGmailAddress</code> - another valid gmail</p>
  
  <p>When I run my app I get this:   </p>
  
  <pre><code>log4j:ERROR Error occured while sending e-mail notification.
  javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 25;
    nested exception is:
      java.net.ConnectException: Connection timed out: connect
      at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282)
      at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
      at javax.mail.Service.connect(Service.java:297)
      at javax.mail.Service.connect(Service.java:156)
      at javax.mail.Service.connect(Service.java:105)
      at javax.mail.Transport.send0(Transport.java:168)
      at javax.mail.Transport.send(Transport.java:98)
      at org.apache.log4j.net.SMTPAppender.sendBuffer(SMTPAppender.java:416)
      at org.apache.log4j.net.SMTPAppender.append(SMTPAppender.java:256)
      at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
      at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
      at org.apache.log4j.Category.callAppenders(Category.java:206)
      at org.apache.log4j.Category.forcedLog(Category.java:391)
      at org.apache.log4j.Category.error(Category.java:305)
      at epam.lab.log4j.utils.Printer.printMessage(Printer.java:13)
      at epam.lab.log4j.Launcher.main(Launcher.java:35)
  Caused by: java.net.ConnectException: Connection timed out: connect
      at java.net.DualStackPlainSocketImpl.connect0(Native Method)
      at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
      at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
      at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
      at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
      at java.net.Socket.connect(Socket.java:589)
      at java.net.Socket.connect(Socket.java:538)
      at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
      at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
      at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
      ... 15 more
  </code></pre>
  
  <p>I spent several hours when tried to solve this, but I do not found solution.
  I tried to change port, disable Antivirus&amp;Firewall, use custom <code>SMTPAppender</code> etc...But it did not help...<br>
  Any ideas how to solve this?</p>