Configuration of email delivery with SMTP

Preamble

The server supports multiple email providers. This guide will explain how to configure the Psono server to use SMTP for email delivery.

Configuration

During the installation of the server you have created a settings.yaml that needs to be adjusted now.

  1. Configure email address

    EMAIL_FROM: '[email protected]'
    

    All emails that are sent by the server will come from this email address.

  2. Add Mailjet API credentials to setting.yml

    EMAIL_BACKEND: 'django.core.mail.backends.smtp.EmailBackend'
    EMAIL_HOST: 'YOUR_EMAIL_HOST'
    EMAIL_HOST_USER: 'YOUR_EMAIL_HOST_USER'
    EMAIL_HOST_PASSWORD: 'YOUR_EMAIL_HOST_PASSWORD'
    EMAIL_PORT: 'YOUR_EMAIL_PORT'
    EMAIL_USE_TLS: 'YOUR_EMAIL_USE_TLS'
    EMAIL_USE_SSL: 'YOUR_EMAIL_USE_SSL'
    EMAIL_SSL_CERTFILE: 'YOUR_EMAIL_SSL_CERTFILE'
    EMAIL_SSL_KEYFILE: 'YOUR_EMAIL_SSL_KEYFILE'
    EMAIL_TIMEOUT: 'YOUR_EMAIL_TIMEOUT'
    
    • Replace YOUR_EMAIL_HOST with your SMTP’s host. e.g. localhost or 192.168.0.5
    • Replace YOUR_EMAIL_HOST_USER with your SMTP’s user.
    • Replace YOUR_EMAIL_HOST_PASSWORD with your SMTP’s password.
    • Replace YOUR_EMAIL_PORT with your SMTP’s port, e.g. 25
    • Replace YOUR_EMAIL_USE_TLS with true or false. Whether to use a TLS (secure) connection when talking to the SMTP server. This is used for explicit TLS connections, generally on port 587. If you are experiencing hanging connections, see the implicit TLS setting EMAIL_USE_SSL.
    • Replace EMAIL_USE_SSL with true or false. Whether to use an implicit TLS (secure) connection when talking to the SMTP server. In most email documentation this type of TLS connection is referred to as SSL. It is generally used on port 465. If you are experiencing problems, see the explicit TLS setting EMAIL_USE_TLS.
    • (optional) Replace YOUR_EMAIL_SSL_CERTFILE (If EMAIL_USE_SSL or EMAIL_USE_TLS is True) with the path to a PEM formatted certificate chain file to use for the SSL connection
    • (optional) Replace YOUR_EMAIL_SSL_KEYFILE (If EMAIL_USE_SSL or EMAIL_USE_TLS is True) with the path to a PEM formatted key file to use for the SSL connection.
    • (optional) Replace EMAIL_TIMEOUT to specify a timeout in seconds for blocking operations like the connection attempt.

Testing

To send a test email to [email protected] execute:

python3 ./psono/manage.py sendtestmail [email protected]

or with docker:

docker run --rm \
  -v /path/to/modified/settings.yaml:/root/.psono_server/settings.yaml \
  -ti psono/psono-server:latest python3 ./psono/manage.py sendtestmail [email protected]

If you receive this test email, then email should be configured proper.

More Information

Psono is using standard django under the hood for SMTP. You can check out the official documentation here:

docs.djangoproject.com/en/2.2/ref/settings/

Edit me
Tags: