Skip to content
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

Send via SMTP support for aliases #869

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ca245b2
Create initial SMTP handler
sahilph Mar 31, 2022
a93696e
Add helper functions to SMTPCredentials class
sahilph Apr 1, 2022
fbfc714
Modify Front-end for SMTP support
sahilph Apr 1, 2022
334ab93
Fix smtp-for-aliases-section checkbox issue
sahilph Apr 1, 2022
d07af51
Change script type to module
sahilph Apr 1, 2022
dfdbf0d
Improve SMTP password logic
sahilph Apr 1, 2022
26fdf52
Add __repr__ to SMTP Credentials class
sahilph Apr 1, 2022
fb65e0c
Add decode to auth_data in SMTP_handler
sahilph Apr 1, 2022
42c4c80
Add auto-generated migrations
sahilph Apr 1, 2022
7b5181c
Change Default port to 465 for SMTP_handler
sahilph Apr 1, 2022
7673644
Format code with: poetry run black
sahilph Apr 1, 2022
25b8ee8
Revert "Add auto-generated migrations"
sahilph Apr 1, 2022
8387ecd
Fix email logging
sahilph Apr 1, 2022
c512e77
Re-enable is_SMTP in EmailLog
sahilph Apr 2, 2022
73f3d09
Fix filtering for SMTP enabled aliases
sahilph Apr 2, 2022
ba2a047
Add auto-generated migrations
sahilph Apr 2, 2022
1af6fcf
Add SMTP variables to example.env
sahilph Apr 2, 2022
84ec9e2
Add about SMTP handler to README
sahilph Apr 2, 2022
48da27a
Add command to generate self-signed certs in README
sahilph Apr 3, 2022
b717f79
change SMTP_password to lowercase.
sahilph Apr 3, 2022
40eab54
Suffix PATH to key/cert vars to be explicit
sahilph Apr 3, 2022
98d1ff9
add unique=True in alias_id declaration
sahilph Apr 3, 2022
93335a6
Revert "Add auto-generated migrations"
sahilph Apr 2, 2022
cc07d6b
Change set_password part
sahilph Apr 3, 2022
aec499e
ReFormat index and setting htmls using Pycharm
sahilph Apr 3, 2022
25a56ec
Add auto-generated migrations
sahilph Apr 3, 2022
a00fc10
Get alias domain by get_email_domain_part in SMTP_handler
sahilph Apr 3, 2022
66b31bb
Add "Send a test email via SMTP" in CONTRIBUTING
sahilph Apr 3, 2022
82da27b
Revert "ReFormat index and setting htmls using Pycharm"
sahilph Apr 3, 2022
6180a80
Re-format again with PyCharm
sahilph Apr 3, 2022
8a5efb2
Redo Change JS vars to camelcase
sahilph Apr 3, 2022
b8ec8aa
Remove `__table_args__` when `unique=True` in models.py
sahilph Apr 15, 2022
18c0a02
Revert keeping original header in email_handler.py
sahilph Apr 15, 2022
a2901e2
Handle sending to reverse alias in SMTP_handler
sahilph Apr 15, 2022
e0b7fc3
Revert "Add auto-generated migrations"
sahilph Apr 3, 2022
32d6a73
Add auto-generated migrations
sahilph Apr 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,11 @@ python email_handler.py
swaks --to e1@sl.local --from hey@google.com --server 127.0.0.1:20381
```

4) Send a test email via SMTP
* Make sure SMTP is enabled in settings and password is generated for the alias

```bash
swaks --to hey@google.com --from e1@sl.local --server 127.0.0.1:465 --tls-on-connect --auth --auth-user e1@sl.local
```

Now open http://localhost:1080/ (or http://localhost:1080/ for MailHog), you should see the forwarded email.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,40 @@ docker run -d \
simplelogin/app:3.4.0 python job_runner.py
```

#### Enable Sending via SMTP

For sending via SMTP you need to make sure you have the required SSL certificate and key at following, as SMTP requires SSL.

- `$(pwd)/smtp_ssl_cert.pem` for SSL Certificate file,
sahilph marked this conversation as resolved.
Show resolved Hide resolved
- `$(pwd)/smtp_ssl_privkey.key` for Key file.
- adjust this according to where you have the files present.

You can use the following command to generate a self-signed certificate for testing.

```bash
openssl req -x509 -newkey rsa:4096 -keyout smtp_ssl_privkey.key \
-out smtp_ssl_cert.pem -sha256 -days 3650 -nodes \
-subj "/C=US/ST=Oregon/L=Portland/O=My Company/OU=Org/CN=mydomain.com"
```

then run `SMTP handler`

```bash
docker run -d \
--name sl-smtp \
-v $(pwd)/sl:/sl \
-v $(pwd)/sl/upload:/code/static/upload \
-v $(pwd)/simplelogin.env:/code/.env \
-v $(pwd)/dkim.key:/dkim.key \
-v $(pwd)/dkim.pub.key:/dkim.pub.key \
-v $(pwd)/smtp_ssl_cert.pem:/smtp_ssl_cert.pem
-v $(pwd)/smtp_ssl_privkey.key:/smtp_ssl_privkey.key
-p 465:465 \
nguyenkims marked this conversation as resolved.
Show resolved Hide resolved
--restart always \
--network="sl-network" \
simplelogin/app:3.4.0 python SMTP_handler.py
```

### Nginx

Install Nginx and make sure to replace `mydomain.com` by your domain
Expand Down