ASF Bugzilla – Attachment 14843 Details for
Bug 24969
SMTPAppender should be able to do auth
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Improved AUTH patch
SMTPAppender.java.patch (text/plain), 2.51 KB, created by
Evan
on 2005-04-26 15:32:25 UTC
(
hide
)
Description:
Improved AUTH patch
Filename:
MIME Type:
Creator:
Evan
Created:
2005-04-26 15:32:25 UTC
Size:
2.51 KB
patch
obsolete
>--- Downloads/logging-log4j-1.2.9/src/java/org/apache/log4j/net/SMTPAppender.java Mon Nov 1 20:21:14 2004 >+++ Softdev/lusightDev/lusight/source/com/lusight/log4j/SMTPAppender.java Tue Apr 26 09:13:45 2005 >@@ -19,6 +19,8 @@ > import java.util.Date; > > import javax.mail.Session; >+import javax.mail.Authenticator; >+import javax.mail.PasswordAuthentication; > import javax.mail.Transport; > import javax.mail.Message; > import javax.mail.MessagingException; >@@ -47,8 +49,11 @@ > private String from; > private String subject; > private String smtpHost; >+ private String smtpUsername; >+ private String smtpPassword; > private int bufferSize = 512; > private boolean locationInfo = false; >+ private boolean smtpDebug = false; > > protected CyclicBuffer cb = new CyclicBuffer(bufferSize); > protected Message msg; >@@ -85,8 +90,23 @@ > if (smtpHost != null) > props.put("mail.smtp.host", smtpHost); > >+ Authenticator authenticator = null; >+ >+ if(smtpPassword != null && smtpUsername != null) { >+ // Setup mail server authentication >+ props.put("mail.smtp.auth", "true"); >+ >+ authenticator = new Authenticator() { >+ protected PasswordAuthentication getPasswordAuthentication() { >+ return new PasswordAuthentication(smtpUsername, smtpPassword); >+ } >+ }; >+ } >+ >+ // Get session >+ Session session = Session.getDefaultInstance(props,authenticator); >+ session.setDebug(smtpDebug); > >- Session session = Session.getInstance(props, null); > //session.setDebug(true); > msg = new MimeMessage(session); > >@@ -242,7 +262,30 @@ > } > } > >+ /** >+ * The <b>SmtpPassword</b> option takes a string value which should be the password required to authenticate against >+ * the mail server >+ */ >+ public void setSMTPPassword(String smtpPassword) { >+ this.smtpPassword = smtpPassword; >+ } > >+ /** >+ * The <b>SmtpUsername</b> option takes a string value which should be the username required to authenticate against >+ * the mail server >+ */ >+ public void setSMTPUsername(String smtpUsername) { >+ this.smtpUsername = smtpUsername; >+ } >+ >+ /** >+ * Setting the <b>SmtpDebug</b> option to true will cause the mail session to log its server interaction to stdout. >+ * This can be useful when debuging the appender but should not be used during production because username and >+ * password information is included in the output. >+ */ >+ public void setSMTPDebug(boolean debug) { >+ this.smtpDebug = debug; >+ } > > /** > Returns value of the <b>EvaluatorClass</b> option.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 24969
:
14831
| 14843