I succeeded in getting this to work (using log4j to send logging messages by smtp over ssl).
I think it's appalling that log4j doesn't do this, and it isn't mentioned anywhere in the documentation. I even bought the complete manual for $20, but it doesn't say a word about this obvious issue. So, here's how I got it working. (This one's free, but I'm charging $20 for subsequent posts.) There are two ways to do this. The first way involves only setting properties and creating a configuration file: set the following system property: System.setProperty("mail.smtps.host", "<mailserver_url>"); Note that the second property uses mail.smtps.host rather than mail.smtp.host. In the SMTPAppender's createSession code, it will take what you set with setSMTPHost(...) and use it to set mail.smtp.host, but the smtps protocol provider won't look at that, so you need to set mail.smtps.host. If you need to use password authentication, you need to also set: System.setProperty("mail.smtps.auth", "true"); The reason for this is similar to above. SMTPAppender will set mail.smtp.auth, but that won't have an effect on the smtps Session. You now have to tell JavaMail to use the smtps protocol. My first try at this was to set System.setProperty("mail.transport.protocol", "smtps"); but that doesn't work. JavaMail is still going to use smtp because of some kooky stuff it does to get the protocol provider. It looks like a bug in JavaMail to me, but in any case, it doesn't work. So here's what you have to do. Create a file named javamail.address.map in one of the places documented in the javadoc for javax.mail.Session. In this file, put the line: rfc822=smtps That should do it. If you need to send both secure and insecure logging messages, it could get tricky. You'll have to alter that file on the fly. Or, ... you could use the second approach: Instead of using the javamail.address.map file, subclass SMTPAppender to get access to the Session object it creates. Override the createSession() method. When you want secure email, set the protocol in the session object by doing: session.setProtocolForAddress("rfc822", "smtps"); -- View this message in context: http://www.nabble.com/Problem-in-using-SMTPAppender-with-gmail-tp19570697p19708656.html Sent from the Log4j - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]