Send mail in javax.mail without authentication

后端 未结 2 545
难免孤独
难免孤独 2020-12-09 08:39

I am using javax.mail to send mails in Java. Now that a part of the concept of my project changed I have to send a mail without authentication. I will have to change my crea

2条回答
  •  半阙折子戏
    2020-12-09 08:54

    private void createSession() {
      properties.put("mail.smtp.auth",false);
      properties.put("mail.smtp.starttls.enable","true");
      properties.put("mail.smtp.port","587");
      properties.put("mail.smtp.host","smtp.gmail.com");
      properties.put("mail.smtp.username","username(emailid")");
      properties.put("mail.smtp.password","password(mail password)");
    
      Session session=Session.getDefaultInstance(properties,null);
    
    }
    

提交回复
热议问题