MailConnectException while sending mail using java mail api

前端 未结 5 824
北恋
北恋 2020-12-12 05:09

Trying to send an email using java mail api. And I keep getting MailConnectException. I have tried multiple ways to solve it without success.

Exception is thrown by

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 06:05

    This looks like network problem. Even though it could occur due to variety of reasons, like :-

    "Couldn't connect to host, port" could be caused by wrong host name, wrong port, a blocking firewall (on the server, on gateways, even on your own machine), network failure, server downtime, etc.

    Can you connect to the mail server using telnet ?

    Also see this FAQ for some mistakes you committed http://www.oracle.com/technetwork/java/javamail/faq/index.html#commonmistakes

    Read this answer on how to send emails using gmail https://stackoverflow.com/a/47452/3107043

提交回复
热议问题