Skip to content

ISSUE-345: mail sending, privileges #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
## x.y.z (next release)

### Added
- Graylog integration for centralized logging (#TBD)

### Changed

Expand Down
65 changes: 39 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ phpList is an open source newsletter manager. This project is a rewrite of the

## About this package

This is the core module of the successor to phpList 3. It will have the
This is the core module of the successor to phpList 3. It will have the
following responsibilities:

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

## Contributing to this package

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.
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.

### Code of Conduct

Expand All @@ -53,9 +53,11 @@ this code.
## Structure

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


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

You can stop the server with CTRL + C.

#### Development and Documentation
#### Development and Documentation

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).
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).

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

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

```json
"extra": {
"phplist/core": {
"bundles": [
"Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle",
"PhpList\\Core\\EmptyStartPageBundle\\PhpListEmptyStartPageBundle"
]
}
"phplist/core": {
"bundles": [
"Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle",
"PhpList\\Core\\EmptyStartPageBundle\\PhpListEmptyStartPageBundle"
]
}
}
```

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

```json
"extra": {
"phplist/core": {
"routes": {
"homepage": {
"resource": "@PhpListEmptyStartPageBundle/Controller/",
"type": "annotation"
}
}
"phplist/core": {
"routes": {
"homepage": {
"resource": "@PhpListEmptyStartPageBundle/Controller/",
"type": "annotation"
}
}
}
}
```

You can also provide system configuration for your module:

```json
"extra": {
"phplist/core": {
"configuration": {
"framework": {
"templating": {
"engines": [
"twig"
]
}
}
"phplist/core": {
"configuration": {
"framework": {
"templating": {
"engines": [
"twig"
]
}
}
}
}
}
```

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


## Email Configuration

phpList supports multiple email transport providers through Symfony Mailer. The following transports are included:

* Gmail
* Amazon SES
* Mailchimp Transactional (Mandrill)
* SendGrid

For detailed configuration instructions, see the [Mailer Transports documentation](docs/mailer-transports.md).

## Copyright

phpList is copyright (C) 2000-2021 [phpList Ltd](https://www.phplist.com/).
15 changes: 13 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"symfony/error-handler": "^6.4",
"symfony/serializer": "^6.4",
"symfony/monolog-bundle": "^3.10",
"graylog2/gelf-php": "^2.0",
"symfony/serializer-pack": "^1.3",
"symfony/orm-pack": "^2.4",
"doctrine/orm": "^3.3",
Expand All @@ -59,7 +60,15 @@
"masterminds/html5": "^2.9",
"ext-dom": "*",
"league/csv": "^9.23.0",
"doctrine/doctrine-migrations-bundle": "^3.4"
"doctrine/doctrine-migrations-bundle": "^3.4",
"symfony/mailer": "^6.4",
"symfony/google-mailer": "^6.4",
"symfony/amazon-mailer": "^6.4",
"symfony/mailchimp-mailer": "^6.4",
"symfony/sendgrid-mailer": "^6.4",
"symfony/twig-bundle": "^6.4",
"symfony/messenger": "^6.4",
"symfony/lock": "^6.4"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
Expand Down Expand Up @@ -127,9 +136,11 @@
"bundles": [
"Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle",
"Symfony\\Bundle\\MonologBundle\\MonologBundle",
"Symfony\\Bundle\\TwigBundle\\TwigBundle",
"Doctrine\\Bundle\\DoctrineBundle\\DoctrineBundle",
"Doctrine\\Bundle\\MigrationsBundle\\DoctrineMigrationsBundle",
"PhpList\\Core\\EmptyStartPageBundle\\EmptyStartPageBundle"
"PhpList\\Core\\EmptyStartPageBundle\\EmptyStartPageBundle",
"FOS\\RestBundle\\FOSRestBundle"
],
"routes": {
"homepage": {
Expand Down
2 changes: 1 addition & 1 deletion config/PHPMD/rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<!-- rules from the "naming" rule set -->
<rule ref="rulesets/naming.xml/ShortVariable">
<properties>
<property name="exceptions" value="id,ip"/>
<property name="exceptions" value="id,ip,cc"/>
</properties>
</rule>
<rule ref="rulesets/naming.xml/LongVariable">
Expand Down
2 changes: 2 additions & 0 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ framework:
serializer:
enabled: true
enable_attributes: true
mailer:
dsn: '%app.mailer_dsn%'
8 changes: 8 additions & 0 deletions config/config_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ monolog:
path: '%kernel.logs_dir%/%kernel.environment%.log'
level: debug
channels: ['!event']
# Graylog handler disabled for development environment - using local logging only
# graylog:
# type: gelf
# publisher:
# hostname: '%app.config.graylog_host%'
# port: '%app.config.graylog_port%'
# level: debug
# channels: ['!event']
console:
type: console
process_psr_3_messages: false
Expand Down
8 changes: 8 additions & 0 deletions config/config_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ imports:

monolog:
handlers:
# Primary handler for production is Graylog
graylog:
type: gelf
publisher:
hostname: '%app.config.graylog_host%'
port: '%app.config.graylog_port%'
level: error
# Local file logging as backup
main:
type: fingers_crossed
action_level: error
Expand Down
27 changes: 27 additions & 0 deletions config/packages/messenger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This file is the Symfony Messenger configuration for asynchronous processing
framework:
messenger:
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
# failure_transport: failed

transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
async_email:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
auto_setup: true
use_notify: true
check_delayed_interval: 60000
retry_strategy:
max_retries: 3
# milliseconds delay
delay: 1000
multiplier: 2
max_delay: 0

# failed: 'doctrine://default?queue_name=failed'

routing:
# Route your messages to the transports
'PhpList\Core\Domain\Messaging\Message\AsyncEmailMessage': async_email
'PhpList\Core\Domain\Messaging\Message\SubscriberConfirmationMessage': async_email
15 changes: 15 additions & 0 deletions config/parameters.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ parameters:
database_password: '%%env(PHPLIST_DATABASE_PASSWORD)%%'
env(PHPLIST_DATABASE_PASSWORD): 'phplist'

# Email configuration
app.mailer_from: '%%env(MAILER_FROM)%%'
env(MAILER_FROM): '[email protected]'
app.mailer_dsn: '%%env(MAILER_DSN)%%'
env(MAILER_DSN): 'smtp://username:[email protected]:2525'
app.confirmation_url: '%%env(CONFIRMATION_URL)%%'
env(CONFIRMATION_URL): 'https://example.com/confirm/'

# Messenger configuration for asynchronous processing
app.messenger_transport_dsn: '%%env(MESSENGER_TRANSPORT_DSN)%%'
env(MESSENGER_TRANSPORT_DSN): 'doctrine://default?auto_setup=true'

# A secret key that's used to generate certain security-related tokens
secret: '%%env(PHPLIST_SECRET)%%'
env(PHPLIST_SECRET): %1$s

graylog_host: 'graylog.example.com'
graylog_port: 12201
10 changes: 10 additions & 0 deletions config/services/commands.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: false

PhpList\Core\Domain\Messaging\Command\:
resource: '../../src/Domain/Messaging/Command'
tags: ['console.command']

8 changes: 1 addition & 7 deletions config/services/managers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ services:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Subscription\Service\SubscriberCsvExporter:
PhpList\Core\Domain\Configuration\Service\Manager\ConfigManager:
autowire: true
autoconfigure: true
public: true

PhpList\Core\Domain\Subscription\Service\SubscriberCsvImporter:
autowire: true
autoconfigure: true
public: true
12 changes: 12 additions & 0 deletions config/services/messenger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
# Register message handlers for Symfony Messenger
PhpList\Core\Domain\Messaging\MessageHandler\:
resource: '../../src/Domain/Messaging/MessageHandler'
tags: [ 'messenger.message_handler' ]

PhpList\Core\Domain\Messaging\MessageHandler\SubscriberConfirmationMessageHandler:
autowire: true
autoconfigure: true
tags: [ 'messenger.message_handler' ]
arguments:
$confirmationUrl: '%app.confirmation_url%'
5 changes: 3 additions & 2 deletions config/packages/app.yml → config/services/parameters.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
app:
config:
parameters:
app.config:
message_from_address: '[email protected]'
admin_address: '[email protected]'
default_message_age: 15768000
Expand All @@ -8,3 +8,4 @@ app:
notify_start_default: '[email protected]'
notify_end_default: '[email protected]'
always_add_google_tracking: true
click_track: true
4 changes: 4 additions & 0 deletions config/services/providers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
PhpList\Core\Domain\Subscription\Service\Provider\SubscriberProvider:
autowire: true
autoconfigure: true
45 changes: 45 additions & 0 deletions config/services/repositories.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,48 @@ services:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Messaging\Model\TemplateImage

PhpList\Core\Domain\Configuration\Repository\ConfigRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Configuration\Model\Config

PhpList\Core\Domain\Messaging\Repository\UserMessageBounceRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Messaging\Model\UserMessageBounce

PhpList\Core\Domain\Messaging\Repository\UserMessageForwardRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Messaging\Model\UserMessageForward

PhpList\Core\Domain\Analytics\Repository\LinkTrackRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Analytics\Model\LinkTrack

PhpList\Core\Domain\Analytics\Repository\UserMessageViewRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Analytics\Model\UserMessageView

PhpList\Core\Domain\Analytics\Repository\LinkTrackUmlClickRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Analytics\Model\LinkTrackUmlClick

PhpList\Core\Domain\Messaging\Repository\UserMessageRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Messaging\Model\UserMessage

PhpList\Core\Domain\Subscription\Repository\SubscriberHistoryRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Subscription\Model\SubscriberHistory

PhpList\Core\Domain\Messaging\Repository\ListMessageRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Subscription\Model\ListMessage
Loading
Loading