Skip to content
Ozzie Isaacs edited this page May 24, 2023 · 2 revisions

Mailserver Setup

For sending E-Mails to your Kindle, Pocketbook, Smartphone or Tablet you need to setup a e-mailserver in Calibre-Web. The corresponding settings are found in the admin section "Edit E-mail Server Settings".\

If you have installed google-auth-oauthlib and google-api-python-client you can choose to use a email address for sending emails without having enabled "less secure apps"

  1. Standard SMTP Servers
  2. Gmail

Standard SMTP Servers

SMTP hostname is the mail-sending server, normally something like smtp.xxx.com. For correct setting of Port and Encryption, please look at the manual of your mail provider. SMTP login and SMTP password are the credentials you are using for sending e-mails. In the from e-mail please enter whatever you want to be shown in the "from field" on the receiver side (Some servers seem to be a bt pitty about what is entered here, you plain email-address should always work).

After finishing the settings you can check if the configuration is correct by hitting "Save setings and send Test E-Mail". Please check afterwards in the task section if the e-mail could be send successfully. If not you can change the loglevel to DEBUG and take a deeper look in the communication-packets and error messages exchanged (logfile calibre-web.log in the root folder of your installation for a manual installed Calibre-Web or in ~/.calibre-web if installed via pip).

The admin user has per default no Kindle-Email address entered, please enter a valid receiving E-Mail address into the corresponding field (admin section user admin, user's own profile settings page).

Gmail

Make sure to have installed google-auth-oauthlib and google-api-python-client from the optional-requirements.txt file.

Go to the Google Developer Console and create a new app. https://console.developers.google.com. If you are using the Google Drive integration, some steps can be skipped and you can use the same oauth key for Gmail and G-Drive

  1. After login create a project:

Dashboard

  1. Choose a name and save the project:

Create project

  1. Activate the API for the created project by clicking on enable APIs and services or API library

Activate API

  1. Choose Gmail API from the listed Apps

API Library

  1. Enable the Gmail API by clicking on enable

Enable GMail

  1. Click on create credentials in the following screen:

API enabled Dashboard

  1. Choose Gmail as API, select user data and go to the next screen

Credential Type

  1. Select a name for your App enter user support and developer email address (can all be the same and identical to the account email you are using)

Consent screen

  1. On the following page select the scopes of the API you want to use (it's optional). Tick "gmail.send" and "userinfo.email"

Scopes

Scopes Detail 1

Scopes Detail 2

  1. On the next screen select "Desktop app" the name can be left on the default value

OAuth Client ID

  1. On the next screen you can download the credentials in a json formatted file. Download the file rename it to gmail.json and put it into the calibre-web root folder or in ~/.calibre-web for installations via pip

Done

  1. Last step (not necessary if you have enabled G-Drive and are providing a valid callback path). Enter the name of the email account you want to use as test user. Click on Oauth consent screen and then on Add users, enter the email address. It should show up in the test users list afterwards

Create test user

  1. Finally, restart Calibre-Web and go to admin section "Edit E-mail Server Settings" and change Server Type to Gmail Account with OAuth2 Verification. Click on Setup Gmail Account

Allowed domains for registering

If public registration is enabled you can limit the domains of e-mail addresses which are allowed for registering. Per default all domains (*.*) are allowed. You can use "*" for limiting to any number of characters and "?" for limiting to exact one character. If you want to limit the domains, please make sure to delete/edit the "*.*" entry. Entries can be deleted by clicking on the trashcan symbol and edited by clicking on the entry.

Extra steps for Docker Container

  1. Enter shell of the docker container
  2. Inside docker app: get PID of current calibre app: ps -C "python3 /app/calibre-web/cps.py" -o pid=
  3. Run the following command to kill the current calibre-web and restart it to get realtime output in terminal: kill [PID FROM STEP 2] && python3 /app/calibre-web/cps.py &
  4. Click on "Setup gmail account as email server" button in Calibre-Web.
  5. Copy link in terminal and open in any browser. Follow prompts and Allow access.
  6. Copy the link from browser (will fail) and paste in docker container: curl "LOCALHOST LINK FROM BROWSER" Keep the double quotes around the link.
  7. Exit container shell and restart container, then test email send. Should work.

Src: https://github.com/janeczku/calibre-web/issues/2254#issuecomment-1100838560