javax.mail.MessagingException: Could not connect to SMTP host?

后端 未结 4 1502
谎友^
谎友^ 2021-01-02 19:14

following is my code to send mail:

import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.Message.Recipie         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-02 19:38

    What causes your problem is right there in the stack trace:

    java.net.ConnectException: Connection refused: connect
    

    do you need a password to connect to the SMTP server? Are you sure you are using the right settings (as in port number)? Are you behind a proxy or a firewall? Can you use those settings in a regular mail program (e.g. Thunderbird) and send mails?

提交回复
热议问题