Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8533663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:01:09+00:00 2026-06-11T10:01:09+00:00

Is there any way to send an email using Java log4j via an exchange

  • 0

Is there any way to send an email using Java log4j via an exchange server that only allows NTLM-based authentication?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:01:10+00:00Added an answer on June 11, 2026 at 10:01 am

    The default appender relies just on SMTP auth, so it won’t make it by itself. You could create a custom email appender as stated here (linked just to state who shared the idea first, it’s not mine). It basically creates the appender where Authentication is done

    import java.util.Properties;
    
    import javax.mail.Authenticator;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    
    import org.apache.log4j.net.SMTPAppender;
    
    /**
    * @author DEV
    *
    */
    public class GmailAppender extends SMTPAppender {
    private boolean startTLS = false;
    
    @Override
    protected Session createSession() {
    Properties props = null;
    try {
    props = new Properties(System.getProperties());
    } catch (SecurityException ex) {
    props = new Properties();
    }
    String prefix = "mail.smtp";
    if (this.getSMTPProtocol() != null) {
    props.put("mail.transport.protocol", this.getSMTPProtocol());
    prefix = "mail." + this.getSMTPProtocol();
    }
    
    if (this.getSMTPHost() != null)
    props.put(prefix + ".host", this.getSMTPHost());
    if (this.getSMTPPort() > 0)
    props.put(prefix + ".port", String.valueOf(this.getSMTPPort()));
    if (this.startTLS)
    props.put("mail.smtp.starttls.enable", "true");
    
    Authenticator auth = null;
    if (this.getSMTPPassword() != null && this.getSMTPUsername() != null) {
    props.put(prefix + ".auth", "true");
    auth = new Authenticator() {
    ...
    

    And then, in the config file,

    #email appender
    log4j.appender.mail=com.horri.GmailAppender
    #defines how othen emails are send
    log4j.appender.mail.BufferSize=1
    log4j.appender.mail.SMTPHost=smtp.gmail.com
    log4j.appender.mail.From=yourmail@servermail.com
    log4j.appender.mail.To=yourmail@gmail.com
    log4j.appender.mail.startTLS = true
    log4j.appender.mail.SMTPUsername=yourgmailusername
    log4j.appender.mail.SMTPPassword=yourgmailpasswd
    log4j.appender.mail.Subject=Log ...
    log4j.appender.mail.threshold=error
    log4j.appender.mail.layout=org.apache.log4j.PatternLayout
    log4j.appender.mail.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
    

    **EDIT: Sometimes helpful gets mixed with “laziness-supportive”. Hence, here’s a apache-licensed implementation of NTLM auth. http://code.google.com/p/ntlm-java/ Hope it works fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there any way that when i user send an email to admin@xx.com the
once we send email from php using mail() function, is there any way to
I'm using EmailComposerTask to send an email. Is there any way to detect if
Is there any way I can send an email, like any frameworks or something.
I know that soap can send XML over http, is there any way to
Is there any way to get the From email address via code in PHP
I have code to send email using Exchange Web Services (EWS 1.1 API). There
As my question says, is there any possible way to send an email from
I'm using tables because I need to send an html email. any way my
Is there any way to view an email using MailMessage rather than sending the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.