How to send an email using MS exchange server

前端 未结 8 2342
一整个雨季
一整个雨季 2020-12-13 16:58

I am trying to sent an email using my company\'s mail server. But I am getting the following exception

Caused by: com.sun.mail.smtp.SMTPSendFailedException:          


        
8条回答
  •  醉酒成梦
    2020-12-13 17:34

    Please use the following code parts instead of Transport.send(message);

    MimeMessage message = new MimeMessage(session);
    
    message.saveChanges();
    Transport transport = session.getTransport("smtp");
    transport.connect(host, "user", "pwd");
    transport.sendMessage(message, message.getAllRecipients());
    transport.close();
    

    I have tested in the local and it is working

提交回复
热议问题