Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Added help documentation for base SMTP and relay SMTP configuration + a fix made for #2088 in settings.

NyanKiyoshicacc84350ca6
diff --git a/docs/guides.rst b/docs/guides.rst
index 4aa6ea9b76..3339b36e0f 100644
--- a/docs/guides.rst
+++ b/docs/guides.rst
@@ -2,9 +2,10 @@ Guides
======
.. toctree::
- :maxdepth: 1
+ :maxdepth: 2
guides/orders
guides/navigation
guides/taxes
guides/recaptcha
+ guides/email_integration
diff --git a/docs/guides/email_integration.rst b/docs/guides/email_integration.rst
new file mode 100644
index 0000000000..a029705c2a
--- /dev/null
+++ b/docs/guides/email_integration.rst
@@ -0,0 +1,81 @@
+Email Configuration and Integration
+===================================
+
+Saleor offers a few ways to set-up your email settings over SMTP servers and relays.
+
+The global, and basic way saleor offers is to set the following ``EMAIL_URL`` environment variable to the target URL,
+which will contain a straightforward value as bellow examples.
+
+
+Example Configurations
+----------------------
+
+
+.. table::
+
+ ========================================================== ================================================================================
+ Description URL
+ ========================================================== ================================================================================
+ GMAIL with **SSL on**. ``smtp://[email protected]:[email protected]:465/?ssl=True``
+ OVH with **STARTTLS on**. ``smtp://[email protected]:[email protected]:587/?tls=True``
+ A SMTP server unencrypted. ``smtp://[email protected]:[email protected]:25/``
+ ========================================================== ================================================================================
+
+
+
+Sendgrid Integration
+--------------------
+
+After you `created your sendgrid application <https://app.sendgrid.com/guide/integrate/langs/smtp>`_,
+you need to set the environment variable ``EMAIL_URL`` as bellow,
+but by replacing ``YOUR_API_KEY_HERE`` with your API key.
+
+``smtp://apikey:[email protected]:465/?ssl=True``
+
+Then, you have to set the environment variable ``DEFAULT_FROM_EMAIL`` to the email address you want to use as the sender email.
+
+Example: ``export [email protected]``
+
+.. note::
+
+ If your 'from email' address is your domain, you need to make sure you at least correctly set your
+ `SPF <https://sendgrid.com/docs/Glossary/spf.html>`_ DNS record and, optionally, set your
+ `DKIM <https://sendgrid.com/docs/Glossary/dkim.html>`_ DNS record as well.
+
+
+Mailgun Integration
+-------------------
+
+After you `added your domain in Mailgun and correctly set-up your domain DNS records <https://app.mailgun.com/app/domains/new>`_,
+you can set the environment variable ``EMAIL_URL`` as bellow,
+but by replacing everything capitalized, with your data.
+
+``smtp://YOUR_LOGIN_NAME@YOUR_DOMAIN_NAME:[email protected]:465/?ssl=True``
+
+
+Example
++++++++
+
+Let's say my domain name is ``smtp.example.com`` and I want to send emails as ``[email protected]``
+and my password is ``my-mailgun-password``.
+
+.. image:: https://i.imgur.com/pdJjBnD.png
+
+I have to set ``EMAIL_URL`` to:
+
+``smtp://[email protected]:[email protected]:465/?ssl=True``
+
+
+
+Mailjet Integration
+-------------------
+
+After `adding your domain in Mailjet <https://app.mailjet.com/account/sender/domain#create-domain>`_,
+you have to set the environment variable ``EMAIL_URL`` as bellow,
+but by replacing everything capitalized, with your data, available at this `URL <https://app.mailjet.com/account/setup>`_\.
+
+``smtp://YOUR_MAILJET_USERNAME:[email protected]:587/?tls=True``
+
+Then, you have to set the environment variable ``DEFAULT_FROM_EMAIL`` to the email address you want to use as the sender email.
+
+Example: ``export [email protected]``
diff --git a/saleor/settings.py b/saleor/settings.py
index 3daad40469..dabe034c49 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -110,7 +110,7 @@ ENABLE_SSL = get_bool_from_env('ENABLE_SSL', False)
if ENABLE_SSL:
SECURE_SSL_REDIRECT = not DEBUG
-DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL')
+DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL', EMAIL_HOST_USER)
ORDER_FROM_EMAIL = os.getenv('ORDER_FROM_EMAIL', DEFAULT_FROM_EMAIL)
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')