Skip to content

Commit ee284c0

Browse files
TatevikGrtatevikg1
andauthored
ISSUE-345: mail sending, privileges (#340)
* ISSUE-345: mailer packages * ISSUE-345: add env * ISSUE-345: refactor * ISSUE-345: tests * ISSUE-345: fix params * ISSUE-345: doc + params * ISSUE-345: async emails * fix admin/token relation * remove twig from dependencies * configure twig * remove twig * ISSUE-345: config manager * ISSUE-345: admin privileges * ISSUE-345: admin privileges * ISSUE-345: deprecation fix * ISSUE-345: attribute type validator * ISSUE-345: remove not used imports * ISSUE-345: register repos * ISSUE-345: fix dql * ISSUE-345: add fos * ISSUE-12: subscription confirmation email (#342) * ISSUE-12: subscription confirmation * ISSUE-12: subscription confirmation async * ISSUE-12: configs * ISSUE-12: configs + style --------- Co-authored-by: Tatevik <[email protected]> * ISSUE-122: delete leaving blacklisted (#343) * ISSUE-122: deleteLeavingBlacklist --------- Co-authored-by: Tatevik <[email protected]> * ISSUE-72: block auth for disabled * Process/send queued campaigns (#344) Co-authored-by: Tatevik <[email protected]> * Add logs (+ graylog option) * Link track service --------- Co-authored-by: Tatevik <[email protected]>
1 parent 6346e2f commit ee284c0

File tree

79 files changed

+4187
-101
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+4187
-101
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
66
## x.y.z (next release)
77

88
### Added
9+
- Graylog integration for centralized logging (#TBD)
910

1011
### Changed
1112

README.md

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ phpList is an open source newsletter manager. This project is a rewrite of the
1616

1717
## About this package
1818

19-
This is the core module of the successor to phpList 3. It will have the
19+
This is the core module of the successor to phpList 3. It will have the
2020
following responsibilities:
2121

2222
* provide access to the DB via Doctrine models and repositories (and raw SQL
@@ -41,7 +41,7 @@ Since this package is only a service required to run a full installation of **ph
4141

4242
## Contributing to this package
4343

44-
Contributions to phpList repositories are highly welcomed! To get started please take a look at the [contribution guide](.github/CONTRIBUTING.md). It contains everything you would need to make your first contribution including how to run local style checks and run tests.
44+
Contributions to phpList repositories are highly welcomed! To get started please take a look at the [contribution guide](.github/CONTRIBUTING.md). It contains everything you would need to make your first contribution including how to run local style checks and run tests.
4545

4646
### Code of Conduct
4747

@@ -53,9 +53,11 @@ this code.
5353
## Structure
5454

5555
* [Class Docs][docs/phpdoc/]
56+
* [Mailer Transports](docs/mailer-transports.md) - How to use different email providers (Gmail, Amazon SES, Mailchimp, SendGrid)
5657
* [Class structure overview](docs/ClassStructure.md)
5758
* [Graphic domain model](docs/DomainModel/DomainModel.svg) and
5859
a [description of the domain entities](docs/DomainModel/Entities.md)
60+
* [Mailer Transports](docs/mailer-transports.md) - How to use different email providers (Gmail, Amazon SES, Mailchimp, SendGrid)
5961

6062

6163
## Running the web server
@@ -79,9 +81,9 @@ already in use, on the next free port after 8000).
7981

8082
You can stop the server with CTRL + C.
8183

82-
#### Development and Documentation
84+
#### Development and Documentation
8385

84-
We use `phpDocumentor` to automatically generate documentation for classes. To make this process efficient and easier, you are required to properly "document" your `classes`,`properties`, `methods` ... by annotating them with [docblocks](https://docs.phpdoc.org/latest/guide/guides/docblocks.html).
86+
We use `phpDocumentor` to automatically generate documentation for classes. To make this process efficient and easier, you are required to properly "document" your `classes`,`properties`, `methods` ... by annotating them with [docblocks](https://docs.phpdoc.org/latest/guide/guides/docblocks.html).
8587

8688
More about generatings docs in [PHPDOC.md](PHPDOC.md)
8789

@@ -124,12 +126,12 @@ listed in the `extra` section of the module's `composer.json` like this:
124126

125127
```json
126128
"extra": {
127-
"phplist/core": {
128-
"bundles": [
129-
"Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle",
130-
"PhpList\\Core\\EmptyStartPageBundle\\PhpListEmptyStartPageBundle"
131-
]
132-
}
129+
"phplist/core": {
130+
"bundles": [
131+
"Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle",
132+
"PhpList\\Core\\EmptyStartPageBundle\\PhpListEmptyStartPageBundle"
133+
]
134+
}
133135
}
134136
```
135137

@@ -144,32 +146,32 @@ the `extra` section of the module's `composer.json` like this:
144146

145147
```json
146148
"extra": {
147-
"phplist/core": {
148-
"routes": {
149-
"homepage": {
150-
"resource": "@PhpListEmptyStartPageBundle/Controller/",
151-
"type": "annotation"
152-
}
153-
}
149+
"phplist/core": {
150+
"routes": {
151+
"homepage": {
152+
"resource": "@PhpListEmptyStartPageBundle/Controller/",
153+
"type": "annotation"
154+
}
154155
}
156+
}
155157
}
156158
```
157159

158160
You can also provide system configuration for your module:
159161

160162
```json
161163
"extra": {
162-
"phplist/core": {
163-
"configuration": {
164-
"framework": {
165-
"templating": {
166-
"engines": [
167-
"twig"
168-
]
169-
}
170-
}
164+
"phplist/core": {
165+
"configuration": {
166+
"framework": {
167+
"templating": {
168+
"engines": [
169+
"twig"
170+
]
171171
}
172+
}
172173
}
174+
}
173175
}
174176
```
175177

@@ -204,6 +206,17 @@ phpList module), please use the
204206
[REST API](https://github.com/phpList/rest-api).
205207

206208

209+
## Email Configuration
210+
211+
phpList supports multiple email transport providers through Symfony Mailer. The following transports are included:
212+
213+
* Gmail
214+
* Amazon SES
215+
* Mailchimp Transactional (Mandrill)
216+
* SendGrid
217+
218+
For detailed configuration instructions, see the [Mailer Transports documentation](docs/mailer-transports.md).
219+
207220
## Copyright
208221

209222
phpList is copyright (C) 2000-2021 [phpList Ltd](https://www.phplist.com/).

composer.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"symfony/error-handler": "^6.4",
4747
"symfony/serializer": "^6.4",
4848
"symfony/monolog-bundle": "^3.10",
49+
"graylog2/gelf-php": "^2.0",
4950
"symfony/serializer-pack": "^1.3",
5051
"symfony/orm-pack": "^2.4",
5152
"doctrine/orm": "^3.3",
@@ -59,7 +60,15 @@
5960
"masterminds/html5": "^2.9",
6061
"ext-dom": "*",
6162
"league/csv": "^9.23.0",
62-
"doctrine/doctrine-migrations-bundle": "^3.4"
63+
"doctrine/doctrine-migrations-bundle": "^3.4",
64+
"symfony/mailer": "^6.4",
65+
"symfony/google-mailer": "^6.4",
66+
"symfony/amazon-mailer": "^6.4",
67+
"symfony/mailchimp-mailer": "^6.4",
68+
"symfony/sendgrid-mailer": "^6.4",
69+
"symfony/twig-bundle": "^6.4",
70+
"symfony/messenger": "^6.4",
71+
"symfony/lock": "^6.4"
6372
},
6473
"require-dev": {
6574
"phpunit/phpunit": "^9.5",
@@ -127,9 +136,11 @@
127136
"bundles": [
128137
"Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle",
129138
"Symfony\\Bundle\\MonologBundle\\MonologBundle",
139+
"Symfony\\Bundle\\TwigBundle\\TwigBundle",
130140
"Doctrine\\Bundle\\DoctrineBundle\\DoctrineBundle",
131141
"Doctrine\\Bundle\\MigrationsBundle\\DoctrineMigrationsBundle",
132-
"PhpList\\Core\\EmptyStartPageBundle\\EmptyStartPageBundle"
142+
"PhpList\\Core\\EmptyStartPageBundle\\EmptyStartPageBundle",
143+
"FOS\\RestBundle\\FOSRestBundle"
133144
],
134145
"routes": {
135146
"homepage": {

config/PHPMD/rules.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<!-- rules from the "naming" rule set -->
5252
<rule ref="rulesets/naming.xml/ShortVariable">
5353
<properties>
54-
<property name="exceptions" value="id,ip"/>
54+
<property name="exceptions" value="id,ip,cc"/>
5555
</properties>
5656
</rule>
5757
<rule ref="rulesets/naming.xml/LongVariable">

config/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ framework:
4040
serializer:
4141
enabled: true
4242
enable_attributes: true
43+
mailer:
44+
dsn: '%app.mailer_dsn%'

config/config_dev.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ monolog:
1414
path: '%kernel.logs_dir%/%kernel.environment%.log'
1515
level: debug
1616
channels: ['!event']
17+
# Graylog handler disabled for development environment - using local logging only
18+
# graylog:
19+
# type: gelf
20+
# publisher:
21+
# hostname: '%app.config.graylog_host%'
22+
# port: '%app.config.graylog_port%'
23+
# level: debug
24+
# channels: ['!event']
1725
console:
1826
type: console
1927
process_psr_3_messages: false

config/config_prod.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ imports:
33

44
monolog:
55
handlers:
6+
# Primary handler for production is Graylog
7+
graylog:
8+
type: gelf
9+
publisher:
10+
hostname: '%app.config.graylog_host%'
11+
port: '%app.config.graylog_port%'
12+
level: error
13+
# Local file logging as backup
614
main:
715
type: fingers_crossed
816
action_level: error

config/packages/messenger.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This file is the Symfony Messenger configuration for asynchronous processing
2+
framework:
3+
messenger:
4+
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
5+
# failure_transport: failed
6+
7+
transports:
8+
# https://symfony.com/doc/current/messenger.html#transport-configuration
9+
async_email:
10+
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
11+
options:
12+
auto_setup: true
13+
use_notify: true
14+
check_delayed_interval: 60000
15+
retry_strategy:
16+
max_retries: 3
17+
# milliseconds delay
18+
delay: 1000
19+
multiplier: 2
20+
max_delay: 0
21+
22+
# failed: 'doctrine://default?queue_name=failed'
23+
24+
routing:
25+
# Route your messages to the transports
26+
'PhpList\Core\Domain\Messaging\Message\AsyncEmailMessage': async_email
27+
'PhpList\Core\Domain\Messaging\Message\SubscriberConfirmationMessage': async_email

config/parameters.yml.dist

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,21 @@ parameters:
2222
database_password: '%%env(PHPLIST_DATABASE_PASSWORD)%%'
2323
env(PHPLIST_DATABASE_PASSWORD): 'phplist'
2424

25+
# Email configuration
26+
app.mailer_from: '%%env(MAILER_FROM)%%'
27+
env(MAILER_FROM): '[email protected]'
28+
app.mailer_dsn: '%%env(MAILER_DSN)%%'
29+
env(MAILER_DSN): 'smtp://username:[email protected]:2525'
30+
app.confirmation_url: '%%env(CONFIRMATION_URL)%%'
31+
env(CONFIRMATION_URL): 'https://example.com/confirm/'
32+
33+
# Messenger configuration for asynchronous processing
34+
app.messenger_transport_dsn: '%%env(MESSENGER_TRANSPORT_DSN)%%'
35+
env(MESSENGER_TRANSPORT_DSN): 'doctrine://default?auto_setup=true'
36+
2537
# A secret key that's used to generate certain security-related tokens
2638
secret: '%%env(PHPLIST_SECRET)%%'
2739
env(PHPLIST_SECRET): %1$s
40+
41+
graylog_host: 'graylog.example.com'
42+
graylog_port: 12201

config/services/commands.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
services:
2+
_defaults:
3+
autowire: true
4+
autoconfigure: true
5+
public: false
6+
7+
PhpList\Core\Domain\Messaging\Command\:
8+
resource: '../../src/Domain/Messaging/Command'
9+
tags: ['console.command']
10+

0 commit comments

Comments
 (0)