Search This Blog

Tuesday, November 13, 2018

How to send email from Office365 / outlook by Java

You need to set the following 4 properties:

    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.port", 587);
    props.put("mail.smtp.host", "smtp.office365.com");
    //or
    props.put("mail.smtp.host", "m.outlook.com");
    props.put("mail.smtp.auth", "true");