git clone "https://github.com/Ankush-Hegde/email-engine"
cd email-engine
-
start the xamp/sql server
-
create the database email_engine
-
migrate the database using
php artisan migrate
command -
change .env.example to .env
-
run the following to generate the encryption key
php artisan key:generate
. -
start and then set up elastic search by using this command
php artisan elasticsearch:setup
-
start the server using
php artisan start
command -
navigate to
localhost:8000
in browser and click on the outlook oauth
get
http://localhost:8000/api/v1/oauth/outlook/generate_url
response
{
"redirect_uri": "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=2fc8eb46-76ba-4ca4-b70f-aed8d77e3a56&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2Fapi%2Fv1%2Foauth%2Foutlook%2Fcallback&scope=openid+offline_access+profile+email+Mail.ReadWrite+Mail.Read+Mail.Send"
}
get
http://localhost:8000/api/v1/oauth/outlook/callback?code=E.V533_BW4.4.D.73cf-32-67-7a-ef0
response
this will return view
Registration | Manage Mails |
---|---|
![]() |
![]() |
post
http://localhost:8000/api/v1/email/fetch
body json
{
"email" : "[email protected]" // used as a session for the simplicity
}
response
[
{
"_index": "emails",
"_id": "AQMkADAwATM3ZmYAZS02ZTLTAwCgBGAAADMAO-kHNvAU_QWj_itP_POwcA4KYOSSojDkC6diOE8kTG-gAAAgEJAAAA4KYOSSojDkC6diOE8kTG-gABGOFl4gAAAA==",
"_score": 0.18232156,
"_source": {
"user_id": 2,
"subject": "Meeting Reminder",
"body": "This is a reminder for our meeting.",
"from": "[email protected]",
"to": [
{
"emailAddress": "[email protected]"
}
],
"cc": [],
"bcc": [],
"is_read": true,
"received_date": "2024-12-08T12:47:45Z",
"sent_date": "2024-12-08T12:47:44Z"
}
},
{
"_index": "emails",
"_id": "AQMkADAwATM3ZmYACLTAwCgBGAAADMAO-kHNvAU_QWj_itP_POwcA4KYOSSojDkC6diOE8kTG-gAAAgEJAAAA4KYOSSojDkC6diOE8kTG-gABGOFl4QAAAA==",
"_score": 0.18232156,
"_source": {
"user_id": 2,
"subject": "Meeting Reminder",
"body": "This is a reminder for our meeting.",
"from": "[email protected]",
"to": [
{
"emailAddress": "[email protected]"
}
],
"cc": [],
"bcc": [],
"is_read": true,
"received_date": "2024-12-08T12:47:19Z",
"sent_date": "2024-12-08T12:47:19Z"
}
}
]
post
http://localhost:8000/api/v1/email/send
body
{
"email": "[email protected]",
"subject": "test email",
"body": "success!!",
"toRecipients": ["[email protected]"]
}
response
{
"message": "Email sent successfully"
}
Send-mail | Send-Success |
---|---|
![]() |
![]() |
as of the requirements,
- need to have user_table, Oauth_table where Oauth_table structure is
| :---: | :---: |
| id | int |
| user_id | int |
| provider_type | (google, microsoft) |
| access_token | string |
| refresh_token | string |
| expair_in | dateTime |
we need to link oAuth table to user table with local user_id
NOTE: as of now, everything is stored in the user table which need to be corrected
we need to have session middleware, where session will be having the type to differenciate the outlook auth and the google auth, now lets assume that everything is hapaning only in the outlook email
[startedOn:07/12/2024] - [endedOn:09/12/2024]
- db elastic search -> SUCCESS!! [startedOn:07/12/2024] - [endedOn:07/12/2024]
- api using oauth -> SUCCESS!! [startedOn:08/12/2024] - [endedOn:08/12/2024]
- Email Data Synchronization -> SUCCESS!! [startedOn:09/12/2024] - [endedOn:09/12/2024] we can improve it by automatically syncing the email
- scalability -> SUCCESS!! [startedOn:08/12/2024] - [endedOn:08/12/2024]
- best practic -> SUCCESS!! [startedOn:08/12/2024] - [endedOn:08/12/2024]
- Extensibility -> SUCCESS!! [startedOn:09/12/2024] - [endedOn:09/12/2024]
- Deliverables docker -> SUCCESS!! [startedOn:07/12/2024] - [endedOn:07/12/2024]
view updated project on :- https://github.com/Ankush-Hegde/email-engine