Lines 19-24
Link Here
|
19 |
import java.util.Date; |
19 |
import java.util.Date; |
20 |
|
20 |
|
21 |
import javax.mail.Session; |
21 |
import javax.mail.Session; |
|
|
22 |
import javax.mail.Authenticator; |
23 |
import javax.mail.PasswordAuthentication; |
22 |
import javax.mail.Transport; |
24 |
import javax.mail.Transport; |
23 |
import javax.mail.Message; |
25 |
import javax.mail.Message; |
24 |
import javax.mail.MessagingException; |
26 |
import javax.mail.MessagingException; |
Lines 47-54
Link Here
|
47 |
private String from; |
49 |
private String from; |
48 |
private String subject; |
50 |
private String subject; |
49 |
private String smtpHost; |
51 |
private String smtpHost; |
|
|
52 |
private String smtpUsername; |
53 |
private String smtpPassword; |
50 |
private int bufferSize = 512; |
54 |
private int bufferSize = 512; |
51 |
private boolean locationInfo = false; |
55 |
private boolean locationInfo = false; |
|
|
56 |
private boolean smtpDebug = false; |
52 |
|
57 |
|
53 |
protected CyclicBuffer cb = new CyclicBuffer(bufferSize); |
58 |
protected CyclicBuffer cb = new CyclicBuffer(bufferSize); |
54 |
protected Message msg; |
59 |
protected Message msg; |
Lines 85-92
Link Here
|
85 |
if (smtpHost != null) |
90 |
if (smtpHost != null) |
86 |
props.put("mail.smtp.host", smtpHost); |
91 |
props.put("mail.smtp.host", smtpHost); |
87 |
|
92 |
|
|
|
93 |
Authenticator authenticator = null; |
94 |
|
95 |
if(smtpPassword != null && smtpUsername != null) { |
96 |
// Setup mail server authentication |
97 |
props.put("mail.smtp.auth", "true"); |
98 |
|
99 |
authenticator = new Authenticator() { |
100 |
protected PasswordAuthentication getPasswordAuthentication() { |
101 |
return new PasswordAuthentication(smtpUsername, smtpPassword); |
102 |
} |
103 |
}; |
104 |
} |
105 |
|
106 |
// Get session |
107 |
Session session = Session.getDefaultInstance(props,authenticator); |
108 |
session.setDebug(smtpDebug); |
88 |
|
109 |
|
89 |
Session session = Session.getInstance(props, null); |
|
|
90 |
//session.setDebug(true); |
110 |
//session.setDebug(true); |
91 |
msg = new MimeMessage(session); |
111 |
msg = new MimeMessage(session); |
92 |
|
112 |
|
Lines 242-248
Link Here
|
242 |
} |
262 |
} |
243 |
} |
263 |
} |
244 |
|
264 |
|
|
|
265 |
/** |
266 |
* The <b>SmtpPassword</b> option takes a string value which should be the password required to authenticate against |
267 |
* the mail server |
268 |
*/ |
269 |
public void setSMTPPassword(String smtpPassword) { |
270 |
this.smtpPassword = smtpPassword; |
271 |
} |
245 |
|
272 |
|
|
|
273 |
/** |
274 |
* The <b>SmtpUsername</b> option takes a string value which should be the username required to authenticate against |
275 |
* the mail server |
276 |
*/ |
277 |
public void setSMTPUsername(String smtpUsername) { |
278 |
this.smtpUsername = smtpUsername; |
279 |
} |
280 |
|
281 |
/** |
282 |
* Setting the <b>SmtpDebug</b> option to true will cause the mail session to log its server interaction to stdout. |
283 |
* This can be useful when debuging the appender but should not be used during production because username and |
284 |
* password information is included in the output. |
285 |
*/ |
286 |
public void setSMTPDebug(boolean debug) { |
287 |
this.smtpDebug = debug; |
288 |
} |
246 |
|
289 |
|
247 |
/** |
290 |
/** |
248 |
Returns value of the <b>EvaluatorClass</b> option. |
291 |
Returns value of the <b>EvaluatorClass</b> option. |