Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If configure, mailer allows to send emails through an Mail Server, its configuration can be found on the config.py file.

Warning

Only available when mailer is set

The mail body request is represented by the following model

email send
PropertyDescriptionDefaultTypeRequired
from_emailFrom to display in the email[email protected]string

No (Gmail)

Yes (Custom SMTP)

to_emailTest destination for List of all the email addresses that will be recipients of the emails sent.-stringlistYes
subjectSubject, if none is defined in configurationEmail SubjectstringNo
data_urlURL to be added to the messagehttp://example.com/stringNo
usernameUsername used in the mail body-stringYes
Tip

The body of the mail can be modified here models/api/mailer.py

Send Email

Use this endpoint to send an email through the Mail Server. It requires authentication and expects a JSON request body with specific parameters.

Parameters

ParameterType

Descriptionnamestring


Table of Contents
maxLevel2

Example

Code Block
languagebash
POST /es/api/v1/mailer/send
Content-Type: application/json

{
  "from_email": "[email protected]",
  "to_email": "user@example["[email protected]", "recipient2@mail.com"],
  "subject": "Hello",
  "data_url": "http://example.com/",
  "username": "John"
}

Response

Successful Response [200]

Code Block
"Email sent successfully"

Validation Error [422]

Code Block
{
  "detail": [
    {
      "loc": ["body", "to_email"],
      "msg": "Field required",
      "type": "value_error.missing"
    }
  ]
}

Gmail extra configuration


If you intend to use Gmail as the SMTP server for this mailer, be sure to have the email (and Google) account ready for it.

Because if you configure the Mailer section with an email and it's correct password, this issue is going to appear:



This is because Google enforces the usage of Application passwords when allowing access to an account instead of the Account Password.


To enable this Application password you need to follow these steps:

  1. Enable the Two-Factor Authentication (if not enabled).
    1. Go to Security settings in your account.
    2. On the Section "Signing in to Google" there is the option to enable the 2-step authentication.
    3. Follow the steps and enable the authentication.
  2. Create an Application Password.
    1. Go to the Application Passwords section.
    2. Generate a new "Other (Custom name)" password.
      1. Enter a name for the new app password.
      2. Click on "Generate"
      3. This will generate a 16 characters password that is the one you need to use in the GAIA API configuration file.
        1. NOTE: This password is only shown once, so, save it somewhere safe!
  3. Add the new application password to the configuration of SearchAPI.