Linux实现自动发送邮件的功能

1、找不到某类:
**解决方法:**打包时自动生成了META-INF下MANIFEST.MF文件
解压jar包,查看其中的MANIFEST.MF文件:
在每行开头有个空格,结束有个空格,文档最后一行有一行空行将其中用到的jar包目录添加进Class-PAth中。
2、java.lang.NullPointerException
at javax.mail.internet.MimeUtility.getEncoding(MimeUtility.java:226)
at javax.mail.internet.MimeUtility.getEncoding(MimeUtility.java:299)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1375)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1021)
at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:419)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1354)
at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2107)
at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2075)
at com.sendmail.SendMail.sendMail(SendMail.java:187)
at com.sendmail.SendMail.main(SendMail.java:205)

**解决方法:**使用Javamail发送带有附加的时候,出现了这个错误的原因是附件不存在。先判断附件的地址是否正常。
3、
nested exception is:
java.net.UnknownHostException: mail.travelsky.com
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1970)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:642)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at com.sendmail.SendMail.sendMail(SendMail.java:191)
at com.sendmail.SendMail.main(SendMail.java:206)
Caused by: java.net.UnknownHostException: mail.travelsky.com
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:570)
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:141)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:319)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:207)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1938)

你可能感兴趣的:(发送邮件)