Installation | Maintenance | Beyond Lino

The email settings of a Lino site

Most Lino applications send emails to site users or business partners as part of their functionality. Here is an overview of the settings related to sending emails to the outside world.

These settings are usually stored in the local settings module.

local settings module

A module meant to contain Django settings to be shared to multiple sites on this machine, but only on this machine. It is conventionally named lino_local.settings.


Here are the Django settings for sending emails.


A list with one or more email addresses of site maintainers to be notified when an exception happens on the server.


The SMTP host that will accept outgoing mails from this site.

See also


The port to use when submitting outgoing mails from this site to EMAIL_HOST.

See also


The user name to use when connecting to the EMAIL_HOST. If this is empty. Django will try to submit anonymously.

See also


The password to use when connecting as EMAIL_HOST_USER to the EMAIL_HOST.

See How to store secret credentials

See also


The address to use as sender in outgoing mails to the admins


Default value for sender of outgoing emails when application code doesn’t specify it.


The subject prefix to use for emails to the ADMINS.

See Django docs

Lino also uses this in lino.modlib.notify.


Start an SMTP connection that is secure from the beginning using smtplib.SMTP_SSL.

See Django docs


Start an unsecured SMTP connection and then use smtplib.SMTP.starttls() to encrypt it. This is the more secure successor of EMAIL_USE_SSL.

See Django docs


Both EMAIL_SSL_KEYFILE and EMAIL_SSL_CERTFILE may be set. When you have a keyfile, then you must also have a certfile. When none is set, Django will use create_default_context() (which is recommended according to Python Security considerations)

How to store secret credentials

Install the dotenv Python package:

pip install python-dotenv

Create a file ~/.env with this content:


In your file:

import dotenv; secrets = dotenv.dotenv_values()

Helo command rejected: need fully-qualified hostname

You may receive this error message when sending from a machine that has no public FQDN to an SMTP server that has strict smtpd_helo_restrictions.

Here is a hack to make Django use your IP address rather than socket.getfqdn() when sending email. Add the following to your file:

from socket import gethostname, gethostbyname
from django.core.mail import DNS_NAME
ip_addr = gethostbyname(gethostname())
DNS_NAME._fqdn = "[{}]".format(ip_addr)
print("Using your IP address [{}] as FQDN in HELO".format(ip_addr))