# bl-api-plugin-nodemailer

[![npm (scoped)](https://img.shields.io/npm/v/@bugslifesolutions/bl-api-plugin-nodemailer.svg)](https://www.npmjs.
com/package/@bugslifesolutions/bl-api-plugin-nodemailer)
[![CircleCI](https://circleci.com/gh/bugslifesolutions/bl-api-plugin-nodemailer.svg?style=svg)](https://circleci.
com/gh/bugslifesolutions/bl-api-plugin-nodemailer)

## Summary

Mail Sending plugin Based on [Nodemailer](https://www.npmjs.com/package/nodemailer) for the [Reaction API](https://github.com/bugslifesolutions/reaction)

The current implementation processes the 'sendEmail' application event.

Authentication is configurable within the store settings and currently supports the following OAuth2 based authentication methods:
- Google OAuth2 Client Credential flow
- Google OAuth2 Authorization Code flow
- Microsoft Authentication library [msol](https://www.npmjs.com/package/msal) based OAuth2 Client Credential flow
- Microsoft Authentication library [msol](https://www.npmjs.com/package/msal) based OAuth2 Authorization Code flow

## Developer Certificate of Origin
We use the [Developer Certificate of Origin (DCO)](https://developercertificate.org/) in lieu of a Contributor License Agreement for all contributions to BugsLife Solutions open source projects. We request that contributors agree to the terms of the DCO and indicate that agreement by signing all commits made to BugsLife Solutions projects by adding a line with your name and email address to every Git commit message contributed:
```
Signed-off-by: Jane Doe <jane.doe@example.com>
```

You can sign your commit automatically with Git by using `git commit -s` if you have your `user.name` and `user.email` set as part of your Git configuration.

We ask that you use your real name (please no anonymous contributions or pseudonyms). By signing your commit you are certifying that you have the right have the right to submit it under the open source license used by that particular Reaction Commerce project. You must use your real name (no pseudonyms or anonymous contributions are allowed.)

We use the [Probot DCO GitHub app](https://github.com/apps/dco) to check for DCO signoffs of every commit.

If you forget to sign your commits, the DCO bot will remind you and give you detailed instructions for how to amend your commits to add a signature.

## License

   Copyright 2022 BugsLife Solutions

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

## O365 Exchange
https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth

### Microsoft App Registration

PS C:\Users\Lenovo> New-ServicePrincipal -AppId a6e589*************8c98f -ObjectId df2d***************53af

DisplayName                              ObjectId                                AppId
-----------                              --------                                -----
                                         df2d97************53af    a6e58***********c98f


PS C:\Users\Lenovo> Get-ServicePrincipal | fl


DisplayName            :
AppId                  : a6e********8c98f
ObjectId               : df2d*******53af
Sid                    : S-1-5-21-40************98
SidHistory             : {}
Identity               : df2d972*******e53af
Id                     : df2d972*******08e53af
IsValid                : True
ExchangeVersion        : 1.1 (15.0.0.0)
Name                   : df2d972********308e53af
DistinguishedName      : CN=df2d9********e53af,OU=NETORG189455.onmicrosoft.com,OU=Microsoft Exchange
                         Hosted Organizations,DC=NAMPR03A006,DC=PROD,DC=OUTLOOK,DC=COM
ObjectCategory         : NAMPR03A006.PROD.OUTLOOK.COM/Configuration/Schema/Person
ObjectClass            : {top, person, organizationalPerson, user}
WhenChanged            : 2023-10-21 10:09:56 AM
WhenCreated            : 2023-10-21 10:09:56 AM
WhenChangedUTC         : 2023-10-21 2:09:56 PM
WhenCreatedUTC         : 2023-10-21 2:09:56 PM
ExchangeObjectId       : 7bf05****************6578027
OrganizationalUnitRoot : NETORG189455.onmicrosoft.com
OrganizationId         : NAMPR03A006.PROD.OUTLOOK.COM/Microsoft Exchange Hosted
                         Organizations/NETORG189455.onmicrosoft.com -
                         NAMPR03A006.PROD.OUTLOOK.COM/ConfigurationUnits/NETORG189455.onmicrosoft.com/Configuration
Guid                   : 7bf05***************8027
OriginatingServer      : BYAPR03A06DC005.NAMPR03A006.PROD.OUTLOOK.COM
ObjectState            : Changed

WARNING: The ServiceId parameter is being depreciated and will be replaced with ObjectId. Please note that already
existing Exchange Service Principal Service Ids are now known as Object Ids.


PS C:\Users\Lenovo>

PS C:\Users\Lenovo> Add-MailboxPermission -Identity "weborders-noreply@test.com" -User  df2d97*******53af

cmdlet Add-MailboxPermission at command pipeline position 1
Supply values for the following parameters:
AccessRights[0]: FullAccess
AccessRights[1]:

Identity             User                 AccessRights                                                IsInherited Deny
--------             ----                 ------------                                                ----------- ----
730aef82.... S-1-5-21-40589603... {FullAccess}                                                False       False


PS C:\Users\Lenovo>
