I purchased a office 365 account and domain from go daddy I am able to login to office 365 web using my email and password now I used the same user name and password in my Java code which sends emails to end user is failing with authentication issue.

how should I resolve this ? below are the connection details which I am using in my Java code.

public static final String SIMPLE_MAIL_TRANSFER_PROTOCOL = "smtps";
public static final String USERNAME = "*** Email address is removed for privacy ***";
public static final String PASSWORD = "*********";
public static final String FROM_EMAIL = "*** Email address is removed for privacy ***";
public static final String CC_EMAIL = "*** Email address is removed for privacy ***";
public static final String EMAIL_SUBJECT = "Hi From Data Broccoli";
public static final String OUTLOOK_SMTP_SERVER = "smtp.office365.com";
public static final String SMTP_HOST = "mail.smtp.host";
public static final String SMTP_AUTH = "mail.smtp.auth";
public static final String SMTP_PORT = "mail.smtp.port";
public static final int DEFAULT_PORT = 587;
public static final String SMTP_STARTTLS_ENABLE = "mail.smtp.starttls.enable";
public static final String SMTP_STARTTLS_REQUIRED = "mail.smtp.starttls.required";

DEBUG SMTP: Found extension "SIZE", arg "157286400"
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN XOAUTH2"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: Found extension "SMTPUTF8", arg ""
DEBUG SMTP: protocolConnect login, host=smtp.office365.com, user=*** Email address is removed for privacy ***, password=<non-null>
DEBUG SMTP: Attempt to authenticate using mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM XOAUTH2 DEBUG SMTP: Using mechanism LOGIN
DEBUG SMTP: AUTH LOGIN command trace suppressed
DEBUG SMTP: AUTH LOGIN failed
Hibernate: insert into user (authorities, email, first_name, is_active, is_not_locked, join_date, last_login_date, last_login_date_display, last_name, password, profile_image_url, role, user_id, username, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 2020-11-03 12:08:10.917 ERROR 52653 --- [nio-8081-exec-1] d.t.w.resource.UserResource              : 535 5.7.3 Authentication unsuccessful [CH2PR05CA0050.namprd05.prod.outlook.com]

Thanks

Harassment is any behavior intended to disturb or upset a person or group of people. Threats include any threat of suicide, violence, or harm to another. Any content of an adult theme or inappropriate to a community web site. Any image, link, or discussion of nudity. Any behavior that is insulting, rude, vulgar, desecrating, or showing disrespect. Any behavior that appears to violate End user license agreements, including providing product keys or links to pirated software. Unsolicited bulk mail or bulk advertising. Any link to or advocacy of virus, spyware, malware, or phishing sites. Any other inappropriate content or behavior as defined by the Terms of Use or Code of Conduct. Any image, link, or discussion related to child pornography, child nudity, or other child abuse or exploitation. Hi Kali,
Do you use multifactor authentication? If so, you need to use an app password in your code.
See https://docs.microsoft.com/exchange/mail-flow-b... for methods and troubleshooting. --
Diane Poremsky

Give back to the Community. Help the next person who has this issue by indicating if this reply solved your problem.
Click Yes or No below.
Harassment is any behavior intended to disturb or upset a person or group of people. Threats include any threat of suicide, violence, or harm to another. Any content of an adult theme or inappropriate to a community web site. Any image, link, or discussion of nudity. Any behavior that is insulting, rude, vulgar, desecrating, or showing disrespect. Any behavior that appears to violate End user license agreements, including providing product keys or links to pirated software. Unsolicited bulk mail or bulk advertising. Any link to or advocacy of virus, spyware, malware, or phishing sites. Any other inappropriate content or behavior as defined by the Terms of Use or Code of Conduct. Any image, link, or discussion related to child pornography, child nudity, or other child abuse or exploitation.