mail-rss/README.md

121 lines
2.8 KiB
Markdown
Raw Permalink Normal View History

2020-11-12 16:17:33 +01:00
Mail RSS
========
This application allows you to transform emails into an RSS feed without connecting to a mailbox.
![](https://upload.deblan.org/u/2020-11/5fad5081.svg)
Installation
------------
Requirements:
2022-02-16 19:10:14 +01:00
* PHP >= 8.0
2020-11-12 16:17:33 +01:00
* [Symfony requirements](https://symfony.com/doc/4.2/reference/requirements.html)
* MySQL, PostgreSQL or SQLite
* Mailparse module (php-mailparse)
```
$ git clone https://gitnet.fr/deblan/mail-rss.git
$ cd mail-rss
$ cp .env env.local
$ composer install
```
Populate `.env.local`:
- `APP_ENV`: `prod` or `dev`
- `DATABASE_URL`: [read the documentation](https://symfony.com/doc/5.3/doctrine.html#configuring-the-database)
- `APP_DEFAULT_URI`: URI of the application (without trailing slash)
Be sure that the webserver can read/write `private/`, `var/` and `migrations/`.
```
$ php bin/console -e dev doctrine:migrations:diff
$ php bin/console -e dev doctrine:migrations:exe --up DoctrineMigrations\\VersionXXXXXXXXXXXXX
```
And read the doc to publish a symfony app: https://symfony.com/doc/5.3/deployment.html
Usage
-----
Use case: you want to create a feed of a newsletter named "Foo Bar".
```
$ sudo mkdir /var/lib/mailrss
$ sudo chmod 0770 /var/lib/mailrss
$ sudo chown you-web-user:nogroup
```
Add an alias into your mailserver:
```
# /etc/aliases
mailrss-foobar: "| > /var/lib/mailrss/foobar-$(date +%s) && chmod o+rw /var/lib/mailrss/foobar-$(date +%s)"
```
Then run `$ sudo newaliases`.
Add a mailing in the app:
```
$ php bin/console mailing:new "Fo Bar"
# Oops, you made a mistake in the label, let's fix it
$ php bin/console mailing:list
$ php bin/console mailing:rename xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx "Foo bar"
```
2020-12-27 22:26:29 +01:00
With `php bin/console mailing:list --feed`, you retrieve the URL of the feed.
2020-11-12 16:17:33 +01:00
In case of you want to delete the mailing:
```
$ php bin/console mailing:delete xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
```
Finally, create a script run in a cron:
2020-11-12 16:17:33 +01:00
```
#!/bin/sh
cd "/path/to/app"
find /var/lib/mailrss -name "foobar-*" | while read MAIL_FILE; do
MAILING_ID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
2020-11-12 16:17:33 +01:00
php bin/console mail:import "$MAILING_ID" -f "$MAIL_FILE" && rm "$MAIL_FILE"
2020-11-12 16:17:33 +01:00
done
```
You also can import a mail using stdin:
```
$ php bin/console mail:import "$MAILING_ID" < "$MAIL_FILE"
$ command | php bin/console mail:import "$MAILING_ID"
```
2020-12-27 22:26:29 +01:00
The feed can be published therefore accessible via the home page:
```
2020-12-27 22:27:21 +01:00
$ php bin/console mailing:publish xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
2020-12-27 22:26:29 +01:00
# php bin/console mailing:new "Foo bar" --public
# php bin/console mailing:new "Foo bar" -p
```
…and it can be private:
```
2020-12-27 22:27:21 +01:00
$ php bin/console mailing:unpublish xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
2020-12-27 22:26:29 +01:00
```
If you want to create another feed then:
2020-11-12 16:17:33 +01:00
* Create an aliase
* Create a mailing
* Update your script run in the cron
* Get the URI using `mailing:list`