Sending email: failed to connect

别来无恙 提交于 2019-12-12 01:59:24

问题


I am using java to send mail. I want to set the from mail id to xyz@chatmeter.com. When i am using that for sending mail the following exception is generated..

    Exception in thread "main" javax.mail.AuthenticationFailedException: failed to connect
    at javax.mail.Service.connect(Service.java:322)
    at javax.mail.Service.connect(Service.java:172)
    at javax.mail.Service.connect(Service.java:121)
    at javax.mail.Transport.send0(Transport.java:190)
    at javax.mail.Transport.send(Transport.java:120)
    at sendmailtoclient.SendSMTP.sendMail(SendSMTP.java:125)
    at sendmailtoclient.SendSMTP.main(SendSMTP.java:153)

I have used the correct password for the mail account. although it I have used the xyz@gmail.com successfully. If you have code please post to me.

Please help me.

Thanks in advance.


回答1:


It looks like your credentials are wrong or not accepted by gmail.
You need SMTP server for sending mail. You can use one installed on your own machine

One free one is here.

Also check if you have added activation.jar




回答2:


Mostly this error occurs from not having activation.jar and mail.jar on your classpath. Add them as a maven dependency or add in WEB-INF/lib and it should be fine.



来源:https://stackoverflow.com/questions/2469649/sending-email-failed-to-connect

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!