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?

1 Like

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.

That doen't work for me. It always says tls here, no matter what I set MAILER_SECURE to

app_1   | 2022-06-07 09:59:26: App: Mailer Config: {
app_1   |   enabled: true,
app_1   |   host: 'smtp',
app_1   |   port: 25,
app_1   |   security: 'tls',
app_1   |   authUser: '',
app_1   |   authPassword: '********',
app_1   |   noReplyName: 'JoplinServer',
app_1   |   noReplyEmail: 'no-reply@domain.com'
app_1   | }

I'd like do disable security, as I use the postfix relay docker container that doesn't use any encryption

Again, it does work. :slight_smile: Also, the MAILER_SECURITY option (in the .env) should be starttls, and the port is not 25 but 587.

1 Like

What do i do wrong then?

my docker-compose.yaml

version: '3'

services:
    db:
        image: postgres:13
        volumes:
            - ./data/postgres:/var/lib/postgresql/data
        restart: unless-stopped
        env_file: .env
    app:
        image: joplin/server:latest
        depends_on:
            - db
        ports:
            - "22300:22300"
        hostname: joplin
        restart: unless-stopped
        env_file: .env
        networks:
            - proxy_net
            - default
    smtp:
        image: mwader/postfix-relay
        restart: unless-stopped
        environment:
            - POSTFIX_myhostname=smtp.domain.com
            - OPENDKIM_DOMAINS=smtp.domain.com
        volumes:
            - ./postfix-data/lib-postfix:/var/lib/postfix
            - ./postfix-data/mail:/var/mail
            - ./postfix-data/spool-postfix:/var/spool/postfix
            - ./postfix-data/keys:/etc/opendkim/keys

networks:
    proxy_net:
        external: true

my .env

APP_BASE_URL=https://joplin.domain.com
# APP_PORT=22300
# 
DB_CLIENT=pg
POSTGRES_PASSWORD=123456
POSTGRES_DATABASE=joplin
POSTGRES_USER=joplin
POSTGRES_PORT=5432
POSTGRES_HOST=db

MAILER_ENABLED=1
MAILER_HOST=smtp
MAILER_PORT=25
MAILER_SECURE=0
MAILER_NOREPLY_NAME=JoplinServer
MAILER_NOREPLY_EMAIL=no-reply@domain.com

For MAILER_SECURE i tried 0, 1, 2, 3, NONE, FALSE and it always says 'tls' when starting up, no matter what. Also I'd like to use the default config of smtp relay without encryption and listening on port 25 as it's running in its own network anyway. So there's no need for extra security

For server 2.7.x the environment variable is now MAILER_SECURITY and according to this post it can have the value "tls", "starttls" or "none"

1 Like

I just told you, MAILER SECURITY, starttls is what you need. Also, mine works with port 587 so that's an option, too (not only 465).

3 Likes