Skip to content

Commit 6037511

Browse files
Merge branch 'dev'
2 parents efb835a + 6c7c016 commit 6037511

33 files changed

+1190
-887
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ APP_ENV=production
55
APP_URL=https://ddev-ms-email.ddev.site
66
APP_EMAIL_PATH=rest-api-email
77
APP_AUTH_PATH=rest-imapuser
8+
AUTH_PROVIDER=single-imap-user

.github/workflows/run.tests.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ jobs:
3535
- name: Install dependencies
3636
run: composer install --no-progress
3737

38-
- name: Execute Unit Tests
39-
run: ./vendor/bin/phpunit --do-not-cache-result
38+
- name: Execute Unit Tests with AUTH_PROVIDER=single-imap-user
39+
run: AUTH_PROVIDER=single-imap-user ./vendor/bin/phpunit --do-not-cache-result
40+
41+
- name: Execute Unit Tests with AUTH_PROVIDER=local-mail-account
42+
run: AUTH_PROVIDER=local-mail-account ./vendor/bin/phpunit --do-not-cache-result
4043

4144
- name: Check Project Coding Standards
4245
run: vendor/bin/phpcs

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,15 @@ Please refer to the official [documentation](./docs) of **lumen-app-email** for
2020
## Features
2121

2222
**lumen-app-email** follows a service oriented approach.
23-
Services are easily replacable with the help of upfront DI configurations and related bindings.
23+
Services are easily replaceable with the help of upfront DI configurations and related bindings.
2424

2525
**Use lumen-app-email, if you...**
2626
- need a fully functional middleware for communicating with IMAP / SMTP servers
27-
- want to provide webmail solutions with domain-specific sign-in to IMAP accounts
28-
- are looking for a distribution with minimal footprint and easy setup
29-
- require a headless, service oriented standalone application with your infrastructure
30-
31-
**do not use lumen-app-email, if you...**
32-
- are looking for a stateful, session based webmail backend
33-
- need baked-in caching
27+
- want to provide webmail solutions with various authentication methods, such as
28+
- domain-specific sign-in to IMAP accounts, orchestrated by the server
29+
- connecting to IMAP accounts solely configured by the users
30+
- are looking for an email messaging solution with minimal footprint that's easy to distribute
31+
- require a headless, service oriented standalone application in your infrastructure that can also be run frontend agnostic
3432

3533
## API Examples
3634

app/bootstrap/app.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* conjoon
55
* lumen-app-email
6-
* Copyright (c) 2019-2022 Thorsten Suckow-Homberg https://github.com/conjoon/lumen-app-email
6+
* Copyright (c) 2019-2023 Thorsten Suckow-Homberg https://github.com/conjoon/lumen-app-email
77
*
88
* Permission is hereby granted, free of charge, to any person
99
* obtaining a copy of this software and associated documentation
@@ -29,7 +29,6 @@
2929

3030
require_once __DIR__ . '/../../vendor/autoload.php';
3131

32-
use App\Providers\ImapAuthServiceProvider;
3332
use Fruitcake\Cors\CorsServiceProvider;
3433
use Fruitcake\Cors\HandleCors;
3534
use Laravel\Lumen\Bootstrap\LoadEnvironmentVariables;
@@ -55,9 +54,8 @@
5554
);
5655

5756
$app->withFacades();
58-
5957
$app->configure('app');
60-
$app->configure('imapserver');
58+
6159
/*
6260
|--------------------------------------------------------------------------
6361
| Register Container Bindings
@@ -84,7 +82,7 @@
8482
$app->configure('cors');
8583
$app->middleware([HandleCors::class]);
8684

87-
$versions = config("app.api.versions");
85+
$versions = config("app.api.service.email.versions");
8886
$authMiddleware = [];
8987
foreach ($versions as $version) {
9088
$version = ucfirst($version);
@@ -103,7 +101,11 @@
103101
|
104102
*/
105103

106-
$app->register(ImapAuthServiceProvider::class);
104+
$app->configure('auth');
105+
$provider = config("auth.defaults.provider");
106+
$providers = config("auth.providers");
107+
$authProviderClass = $providers[$provider]["providerClass"];
108+
$app->register($authProviderClass);
107109

108110
/*
109111
|--------------------------------------------------------------------------

app/bootstrap/bindings.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* conjoon
55
* lumen-app-email
6-
* Copyright (C) 2019-2022 Thorsten Suckow-Homberg https://github.com/conjoon/lumen-app-email
6+
* Copyright (C) 2019-2023 Thorsten Suckow-Homberg https://github.com/conjoon/lumen-app-email
77
*
88
* Permission is hereby granted, free of charge, to any person
99
* obtaining a copy of this software and associated documentation
@@ -34,7 +34,8 @@
3434
use Conjoon\Horde\Mail\Client\Message\Composer\HordeBodyComposer;
3535
use Conjoon\Horde\Mail\Client\Message\Composer\HordeHeaderComposer;
3636
use Conjoon\Illuminate\Auth\Imap\DefaultImapUserProvider;
37-
use Conjoon\Illuminate\Auth\Imap\ImapUserProvider;
37+
use Conjoon\Illuminate\Auth\ImapUserProvider;
38+
use Conjoon\Illuminate\Mail\Client\Request\Attachment\Transformer\LaravelAttachmentListJsonTransformer;
3839
use Conjoon\Mail\Client\Attachment\Processor\InlineDataProcessor;
3940
use Conjoon\Mail\Client\Data\MailAccount;
4041
use Conjoon\Mail\Client\Folder\Tree\DefaultMailFolderTreeBuilder;
@@ -45,7 +46,6 @@
4546
use Conjoon\Mail\Client\Reader\PurifiedHtmlStrategy;
4647
use Conjoon\Mail\Client\Reader\ReadableMessagePartContentProcessor;
4748
use Conjoon\Mail\Client\Request\Attachment\Transformer\AttachmentListJsonTransformer;
48-
use Conjoon\Illuminate\Mail\Client\Request\Attachment\Transformer\LaravelAttachmentListJsonTransformer;
4949
use Conjoon\Mail\Client\Request\Message\Transformer\DefaultMessageBodyDraftJsonTransformer;
5050
use Conjoon\Mail\Client\Request\Message\Transformer\DefaultMessageItemDraftJsonTransformer;
5151
use Conjoon\Mail\Client\Request\Message\Transformer\MessageBodyDraftJsonTransformer;

app/config/app.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* conjoon
55
* lumen-app-email
6-
* Copyright (c) 2019-2022 Thorsten Suckow-Homberg https://github.com/conjoon/lumen-app-email
6+
* Copyright (c) 2019-2023 Thorsten Suckow-Homberg https://github.com/conjoon/lumen-app-email
77
*
88
* Permission is hereby granted, free of charge, to any person
99
* obtaining a copy of this software and associated documentation
@@ -44,11 +44,12 @@
4444
*/
4545
"api" => [
4646
"service" => [
47-
"email" => env("APP_EMAIL_PATH", "rest-api-email"),
48-
"auth" => env("APP_AUTH_PATH", "rest-imapuser")
49-
],
50-
"versions" => ["v0"],
51-
"latest" => "v0"
47+
"email" => [
48+
"path" => env("APP_EMAIL_PATH", "rest-api-email"),
49+
"versions" => ["v0"],
50+
"latest" => "v0"
51+
]
52+
]
5253
],
5354

5455
/*

app/config/auth.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* conjoon
55
* lumen-app-email
6-
* Copyright (c) 2019-2022 Thorsten Suckow-Homberg https://github.com/conjoon/lumen-app-email
6+
* Copyright (c) 2019-2023 Thorsten Suckow-Homberg https://github.com/conjoon/lumen-app-email
77
*
88
* Permission is hereby granted, free of charge, to any person
99
* obtaining a copy of this software and associated documentation
@@ -27,31 +27,34 @@
2727

2828
declare(strict_types=1);
2929

30+
use App\Providers\LocalAccountServiceProvider;
31+
use App\Providers\ImapAuthServiceProvider;
32+
3033
return [
31-
"defaults" => [
34+
35+
"defaults" => [
3236
"guard" => env("AUTH_GUARD", "api"),
3337

3438
/**
3539
* The default provider.
36-
* Change this to a provider that suits your needs and make
37-
* sure you update app.php with the proper (Auth)ServiceProvider.
3840
*/
39-
"provider" => "single-imap-user"
40-
],
41+
"provider" => env("AUTH_PROVIDER", "single-imap-user")
42+
],
4143

42-
"guards" => [
44+
"guards" => [
4345
"api" => [
4446
"driver" => "api"
4547
],
46-
],
48+
],
4749

48-
"providers" => [
50+
"providers" => [
51+
"local-mail-account" => [
52+
"providerClass" => LocalAccountServiceProvider::class,
53+
"driver" => "LocalAccountProviderDriver"
54+
],
4955
"single-imap-user" => [
50-
/**
51-
* Must be registered in the (Auth)ServiceProvider used with this
52-
* app and allows for returning a custom UserProvider.
53-
*/
56+
"providerClass" => ImapAuthServiceProvider::class,
5457
"driver" => "ImapUserProviderDriver"
5558
]
56-
]
59+
]
5760
];

app/config/imapserver.php.example

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* conjoon
55
* lumen-app-email
6-
* Copyright (c) 2019-2022 Thorsten Suckow-Homberg https://github.com/conjoon/lumen-app-email
6+
* Copyright (c) 2019-2023 Thorsten Suckow-Homberg https://github.com/conjoon/lumen-app-email
77
*
88
* Permission is hereby granted, free of charge, to any person
99
* obtaining a copy of this software and associated documentation
@@ -49,14 +49,14 @@ declare(strict_types=1);
4949
| "outbox_address" => "smtp.gmail.com",
5050
| "outbox_port" => 465,
5151
| "outbox_secure" => "ssl",
52-
| // the root mailbox. For most IMAP servers, this will
52+
| // the mailbox(es) the account is subscribed to.
53+
| // For most IMAP servers, this will
5354
| // be "INBOX". Gmail users can use "[Gmail]" instead.
54-
| // You can also provide a separate mailbox named "conjoon".
55-
| // The root folders are the only folders which will be
55+
| // These mailboxes are the only folders which will be
5656
| // queried and displayed in the folder hierarchy for the
5757
| // Mail Account, along with its contents, including sub folders.
5858
| // leave empty to return all mailboxes
59-
| "root" => ["Gmail"],
59+
| "subscriptions" => ["Gmail"],
6060
| // a regular expression that makes sure a user's email-address
6161
| // is matched against "this" entry, e.g. a sign-in with the
6262
| // username "dev@googlemail.com" would be associated with "this",
@@ -80,7 +80,7 @@ return [
8080
"outbox_address" => "smtp.gmail.com",
8181
"outbox_port" => 465,
8282
"outbox_secure" => "ssl",
83-
"root" => ["INBOX", "[Gmail]", "[Google Mail]"],
83+
"subscriptions" => ["INBOX", "[Gmail]", "[Google Mail]"],
8484
"match" => ["/\@(googlemail.|gmail.)(com)$/mi"]
8585
],
8686

@@ -97,7 +97,7 @@ return [
9797
"outbox_address" => "smtp-mail.outlook.com",
9898
"outbox_port" => 587,
9999
"outbox_secure" => "tls",
100-
"root" => [],
100+
"subscriptions" => [],
101101
"match" => ["/\@(outlook.)(com)$/mi"]
102102
],
103103

@@ -114,7 +114,7 @@ return [
114114
"outbox_address" => "smtp.mail.yahoo.com",
115115
"outbox_port" => 587,
116116
"outbox_secure" => "ssl",
117-
"root" => ["INBOX"],
117+
"subscriptions" => ["INBOX"],
118118
"match" => ["/\@(freenet.)(de)$/mi"]
119119
],
120120

@@ -131,7 +131,7 @@ return [
131131
"outbox_address" => "smtp.aol.com",
132132
"outbox_port" => 465,
133133
"outbox_secure" => "ssl",
134-
"root" => [],
134+
"subscriptions" => [],
135135
"match" => ["/\@(aol.)(com)$/mi"]
136136
],
137137

@@ -148,7 +148,7 @@ return [
148148
"outbox_address" => "mx.freenet.de",
149149
"outbox_port" => 587,
150150
"outbox_secure" => "tls",
151-
"root" => ["INBOX"],
151+
"subscriptions" => ["INBOX"],
152152
"match" => ["/\@(freenet.)(de)$/mi"]
153153
],
154154

@@ -165,7 +165,7 @@ return [
165165
"outbox_address" => "mail.gmx.net",
166166
"outbox_port" => 587,
167167
"outbox_secure" => "tls",
168-
"root" => [],
168+
"subscriptions" => [],
169169
"match" => ["/\@(gmx.)(de|net)$/mi"]
170170
],
171171

@@ -182,7 +182,7 @@ return [
182182
"outbox_address" => "smtp.web.de",
183183
"outbox_port" => 587,
184184
"outbox_secure" => "tls",
185-
"root" => [],
185+
"subscriptions" => [],
186186
"match" => ["/\@(web.)(de)$/mi"]
187187
]
188188

app/routes/rest-api-email/web.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@
3737
*/
3838

3939
$router = $app->router;
40-
$versions = config("app.api.versions");
41-
$latest = config("app.api.latest");
40+
$versions = config("app.api.service.email.versions");
41+
$latest = config("app.api.service.email.latest");
4242

43-
$prefix = config("app.api.service.email");
43+
$prefix = config("app.api.service.email.path");
4444

4545
foreach ($versions as $version) {
4646
$router->group([

app/routes/rest-imapuser/web.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* conjoon
55
* lumen-app-email
6-
* Copyright (C) 2020-2022 Thorsten Suckow-Homberg https://github.com/conjoon/lumen-app-email
6+
* Copyright (C) 2020-2023 Thorsten Suckow-Homberg https://github.com/conjoon/lumen-app-email
77
*
88
* Permission is hereby granted, free of charge, to any person
99
* obtaining a copy of this software and associated documentation
@@ -37,13 +37,13 @@
3737
*/
3838

3939
$router = $app->router;
40-
$versions = config("app.api.versions");
41-
$latest = config("app.api.latest");
40+
$versions = config("app.api.service.imapuser.versions");
41+
$latest = config("app.api.service.imapuser.latest");
4242

43-
$prefix = config("app.api.service.auth");
43+
$prefix = config("app.api.service.imapuser.path");
4444

4545
foreach ($versions as $version) {
46-
$app->router->group([
46+
$router->group([
4747
'namespace' => "App\Http\\" . ucfirst($version) . "\Controllers",
4848
'prefix' => "$prefix/" . $version
4949
], function () use ($router, $version) {

0 commit comments

Comments
 (0)