NoReply mailbox and Send mail using O365 smtp server with Java

Joseph·2024년 11월 7일
0
post-thumbnail

0. Summary

Regarding Exchange online, I was intriguied to see how mail has been sent from any other systems.
So, imagine that you are a developer and you have to integrate and implement function with a exchange online mailbox.

Here is my breif solutions.

1. Create NoReply mailbox(Shared mailbox)

First of all, you need to configure NoReply Mailbox from the Exchange online. Let me skip the procedure and replace the explanation with the following link.

https://www.codetwo.com/admins-blog/no-reply-mailbox-in-microsoft-365/

2. Enable SMTP Authentication

And you need to enable SMTP Authentication for the shared mailbox.
Please refer the MS Documentation which is how to set up this feature globally or for each mailbox.

https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/authenticated-client-smtp-submission

For example:

3. Coding with Java

After enable SMTP Authentication for the mailbox,
You are almost there. Make your own code for a sending message through using O365 SMTP server.
Please take a look at my code from the following github URL.

https://github.com/leeyosebi/SendEmailO365Java

* import jar package first!

You might struggle for the import java mail package which is required for send a email.
There are several ways to import a required modules and packages but I just download the .jar files and import manually.

  1. File > Porject Structure
  2. Modules > Dependencies > Add
  3. Click '1 JARs or Directories'
  4. Select the required .jar files and Open

Now, You can import required module.

4. Result

It successfully works. Let's find the message logs on the EXO first.

  1. It says Delievered.
  2. The messages are found on the shared mailbox as well. Even I didn't enter the mailbox.
  3. The message are found on the recepient mailbox. The sender, subject and body content are exact same as the code we made.

5. MS Documentation

https://learn.microsoft.com/en-us/exchange/mail-flow-best-practices/how-to-set-up-a-multifunction-device-or-application-to-send-email-using-microsoft-365-or-office-365

0개의 댓글