tags:

views:

503

answers:

2
+1  Q: 

Log4j SMTPAppender

Hi everyone,

I have some problems trying to play with SMTPAppender. Here is my property file concerning the SMTPAppender :

#Email config
log4j.appender.mail=org.apache.log4j.net.SMTPAppender
#defines how often emails are send
log4j.appender.mail.BufferSize=1
log4j.appender.mail.SMTPHost=smtp.me.com
log4j.appender.mail.SMTPUsername=username
log4j.appender.mail.SMTPPassword=something
[email protected]
[email protected]
log4j.appender.mail.Subject="Application.log error occurred"
log4j.appender.mail.layout=org.apache.log4j.PatternLayout
log4j.appender.mail.layout.ConversionPattern=%d %5p [%c] %n%m%n

When I launch my program, I have this error message :

 log4j:ERROR Error occured while sending e-mail notification.
javax.mail.MessagingException: Unknown SMTP host: smtp.me.com;
  nested exception is:
    java.net.UnknownHostException: smtp.me.com
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1389)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)

I have to say that I'm totally new in the mail world. And as far as I'm aware smt.me.com exist, it's Apple Mobile Me service.

I wonder if there is a possibility that the problem is due to a special configuration in my work's computer ? Maybe they can scan and stop certain process like this one ?

Would be great to have an answer from you, little genius guys !

Thanks a lot,

F

+1  A: 

First of all, try

dig smtp.me.com

or

nslookup smtp.me.com

On the same workstation where your are running your program. If the above commands don't return a meaningful IP address then you have a DNS issues.

You will need to create an A record for smtp.me.com.

Alexander Pogrebnyak
Thanks, yes nslookup return me an error message ... I will probably have to wait for try at home ?
Farid
@Farid. You can use `/etc/hosts` file to override DNS/provide temporary value for the host name for your test.If you are using Windows, it's found in rather peculiar place: `C:\WINDOWS\system32\drivers\etc\hosts`. Just add line `192.168.0.xxx smtp.me.com`
Alexander Pogrebnyak
A: 

Well I'm now pretty close to have my first success in it.

Could someone let me know how to set the ip for the host in the SMTPAppender ?

Thanks

Farid