Joplin Server 2.2.6 - Email Settings

Apologies if I have missed it being stated somewhere, but how is Joplin server provided with the SMTP host / port / credentials in order to get the reset emails working?

It would be done using the MAILER_ variables as listed here: joplin/config.ts at 67a000add903fc9d0329dc5388564e28f463898a · laurent22/joplin · GitHub

If everything is setup correctly, the EmailService should print a message in the log about it when you start the server.

Eversomanythanks!

OK, got a bit happy a bit too soon.

Are these values to go in the compose file environment: settings and in a format like this?

- MAILER_ENABLED=1
- MAILER_HOST=smtp.example.com
- MAILER_PORT=465
- MAILER_SECURE=true
- MAILER_AUTH_USER=mail@example.com
- MAILER_AUTH_PASSWORD=password
- MAILER_NOREPLY_NAME=JoplinServer
- MAILER_NOREPLY_EMAIL=noreply@example.com

The values look about right, except that there's no true/false - it's always either 0 or 1. I don't know if the way you load them is right. It might be, but I prefer to use a simple .env file with a docker-compose like this:

version: '3'
services:
  server:
    image: joplin/server:2.2.6-beta
    ports:
      - 22300:22300
    env_file: .env

Then in .env file all the variables are listed like so:

MAILER_ENABLED=1
MAILER_HOST=smtp.example.com
# etc.

Thanks again.

I used the settings:

MAILER_ENABLED=1
MAILER_HOST=smtp.example.com
MAILER_PORT=465
MAILER_SECURE=1
MAILER_AUTH_USER=mail@example.com
MAILER_AUTH_PASSWORD=password
MAILER_NOREPLY_NAME=JoplinServer
MAILER_NOREPLY_EMAIL=noreply@example.com

in a separate env file with all the other Joplin Server environment variables. I also found that I had to connect port 465 from the container to 465 on the host before the messages got out so my docker-compose.yml file contained:

version: '3'
services:
  server:
    image: joplin/server:2.2.6-beta
    ports:
      - "22300:22300"
      - "465:465"
    env_file: .env

Anyway, it now works!

2 Likes

@laurent

Related issue further to the above.

I have two Joplin servers (2.2.6-beta) set up on different machines (x86-64 "official" and ARM64 "unofficial"). Email is set up on both servers. However what I have noticed is that pressing the "Send reset email" button in the admin panel does not send the email immediately. The server has to be restarted before the message is sent. This happens on both servers.

I have only noticed this now that I have stopped constantly altering the server config.

Oddly this does not occur for confirmation emails on the one server ("official") which also has "sign-up" activated. They seem to get sent when the account request is received.

In your opinion is this a bug or have I somehow mucked up the config?

Indeed there's a bug here. The email service is set to process the email queue on certain events, but somehow it's only listening to the "user created" event and nothing else (and it also runs when the server starts).

I don't remember why I've implemented it that way but it doesn't make much sense actually. I'm going to simply set it up to schedule email processing every time an email is added to the queue, and that should be much more reliable.

2 Likes

Out of interest is this documented? I see only examples but no clarification. My SMPT server supports None, STARTTLS and SSL/TLS are these 0, 1 and 2 respectively.

OK, bit stuck. I tried 1, and when to the Joplin Server admin User list, selected a user and clicked the "send account confirmation email" button. But see no email. So I changed it to 2, and restarted but that reports only 0 and 1 are legal. The server expects SSL/TLS.

Joplin reports (on its log):

2022-02-02 21:33:31: EmailService: Transporter is operational - service will be enabled
2022-02-02 21:33:31: EmailService: Maintenance completed in 1061ms
2022-02-02 21:33:41: EmailService: Email was queued - scheduling maintenance
2022-02-02 21:33:41: App: POST /users/Zqsshh6O27V3dqRRri14uCOJwb4V7BmS (302) (71ms)
2022-02-02 21:33:41: App: GET /users/Zqsshh6O27V3dqRRri14uCOJwb4V7BmS (200) (32ms)
2022-02-02 21:33:42: App: GET /css/bulma.min.css (200) (2ms)
2022-02-02 21:33:42: App: GET /css/main.css (200) (1ms)
2022-02-02 21:33:42: App: GET /css/fontawesome/css/all.min.css (200) (1ms)
2022-02-02 21:33:42: App: GET /css/index/user.css (200) (1ms)
2022-02-02 21:33:42: App: GET /js/main.js (200) (2ms)
2022-02-02 21:33:42: App: GET /js/jquery.min.js (200) (0ms)
2022-02-02 21:33:42: App: GET /js/zxcvbn.js (200) (1ms)
2022-02-02 21:33:42: App: GET /images/Logo.png (200) (1ms)
2022-02-02 21:33:51: EmailService: Starting maintenance...
2022-02-02 21:33:54: EmailService: Maintenance completed in 3392ms

So an email was queued, and maintenance conducted and no error reported, but no email either.

OK I checked the database email table, and the emails are all in there. It has an error column that reveals the cause. Good to know! The web interface doesn't report that error (because it's async I guess but oddly enough the error does not appear in the log either - as shown above)

Not that I am aware of. I used trial and error and the link @laurent provided above.

During my tests the only other thing I did was map the mailer port within the docker container to the same port on the host.

    ports:
      - "22300:22300"
      - "465:465"

All good. I have it working fine now. Alas I have trouble finding any SMTP provider today who accepts plain password authentication! They've all moved to OAuth (sensibly). So I'm using a legacy Zoho account which supports it, but I like dedicated accounts for such purposes. So here's hoping Joplin Server support OAuth SMTP authentication some time.

Might be a bit older, but you can do something like App Passwords with Gmail. Ran into the same issue before.

It does work with app passwords, for instance, I'm using my Joplin Server with that set up.