简体   繁体   中英

Log4j SMTPAppender

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
log4j.appender.mail.From=Myselft@mac.com
log4j.appender.mail.To=ABeautifulGirlWaitingForMe@SomeWhere.com
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 computer? Maybe they can scan and stop certain process like this one?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM