ASF Bugzilla – Attachment 14831 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]
Patch file to add AUTH support to the email appender
SMTPAppender.java.patch (text/plain), 2.39 KB, created by
Evan
on 2005-04-25 16:35:31 UTC
(
hide
)
Description:
Patch file to add AUTH support to the email appender
Filename:
MIME Type:
Creator:
Evan
Created:
2005-04-25 16:35:31 UTC
Size:
2.39 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/SMTPAppender.java Mon Apr 25 10:29:24 2005 >@@ -7,6 +7,7 @@ > > package org.apache.log4j.net; > >+ > import org.apache.log4j.AppenderSkeleton; > import org.apache.log4j.Level; > import org.apache.log4j.helpers.CyclicBuffer; >@@ -18,12 +19,8 @@ > import java.util.Properties; > import java.util.Date; > >-import javax.mail.Session; >-import javax.mail.Transport; >-import javax.mail.Message; >-import javax.mail.MessagingException; > import javax.mail.internet.MimeMessage; >-import javax.mail.Multipart; >+import javax.mail.*; > import javax.mail.internet.MimeMultipart; > import javax.mail.internet.MimeBodyPart; > import javax.mail.internet.InternetAddress; >@@ -47,6 +44,8 @@ > private String from; > private String subject; > private String smtpHost; >+ private String smtpUsername; >+ private String smtpPassword; > private int bufferSize = 512; > private boolean locationInfo = false; > >@@ -85,8 +84,25 @@ > if (smtpHost != null) > props.put("mail.smtp.host", smtpHost); > >+ // authenticate myself with the server >+ Authenticator authenticator = null; >+ >+ if(smtpPassword != null && smtpUsername != null) { >+ // Setup mail server authentication >+ props.put("mail.smtp.auth", "true"); >+// props.put("mail.transport.protocol", "smtp"); >+ >+ authenticator = new Authenticator() { >+ protected PasswordAuthentication getPasswordAuthentication() { >+ return new PasswordAuthentication(smtpUsername, smtpPassword); >+ } >+ }; >+ } >+ >+ // Get session >+ Session session = Session.getDefaultInstance(props,authenticator); >+ session.setDebug(true); > >- Session session = Session.getInstance(props, null); > //session.setDebug(true); > msg = new MimeMessage(session); > >@@ -242,6 +258,21 @@ > } > } > >+ /** >+ * 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; >+ } > > > /**
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