小编use*_*707的帖子

Transport.send(消息)无法在下面的代码中工作.. netbeans卡在运行部分.它不会继续下去......它永远挂在那里

我曾尝试编写使用Java发送电子邮件的代码.但是这段代码不起作用.当代码执行时,它会卡在transport.send(消息)上.它永远停留在那里.此外,我不确定其余代码是否正确.

  //first from, to, subject, & text values are set
    public class SendMail {
    private String from;
    private String to;
    private String subject;
    private String text;


    public SendMail(String from, String to, String subject, String text){
        this.from = from;
        this.to = to;
        this.subject = subject;
        this.text = text;
    }

    //send method is called in the end 
    public void send(){

        Properties props = new Properties();
        props.put("mail.smtp.host", "smtp.gmail.com");
        props.put("mail.smtp.port", "465");

        Session mailSession = Session.getDefaultInstance(props);
        Message simpleMessage = new MimeMessage(mailSession);

        InternetAddress fromAddress = null; …
Run Code Online (Sandbox Code Playgroud)

java api jakarta-mail netbeans-6.9

8
推荐指数
2
解决办法
3万
查看次数

标签 统计

api ×1

jakarta-mail ×1

java ×1

netbeans-6.9 ×1