SMTP setup issue

I have installed Successfully N8N on AWS Ubuntu Instance, But I am facing an issue with SMTP configuration,
Can anyone tell me in which file I have to put SMTP details or any help regarding this as i am not so tech Savvy

Hey @chandan988,

What issue are you seeing? It would be handy to know what install method you went for, If it was docker it would be a case of setting the environment options with the -e flag or in the compose file if you are using that.

I followed Server Setup | Docs all the steps here

Perfect, Are you currently seeing an error when you try to set them or have you not tried anything yet? I have not tested it but the example below should set the options, We default to using SSL and port 465 so the port nad SSL options are not needed unless you need to change them. I have also removed the basic auth settings as if you are using user management they are not needed.

docker-compose.yml
version: "3"

services:
  traefik:
    image: "traefik"
    restart: always
    command:
      - "--api=true"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
      - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true"
      - "--certificatesresolvers.mytlschallenge.acme.email=${SSL_EMAIL}"
      - "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ${DATA_FOLDER}/letsencrypt:/letsencrypt
      - /var/run/docker.sock:/var/run/docker.sock:ro

  n8n:
    image: n8nio/n8n
    restart: always
    ports:
      - "127.0.0.1:5678:5678"
    labels:
      - traefik.enable=true
      - traefik.http.routers.n8n.rule=Host(`${SUBDOMAIN}.${DOMAIN_NAME}`)
      - traefik.http.routers.n8n.tls=true
      - traefik.http.routers.n8n.entrypoints=web,websecure
      - traefik.http.routers.n8n.tls.certresolver=mytlschallenge
      - traefik.http.middlewares.n8n.headers.SSLRedirect=true
      - traefik.http.middlewares.n8n.headers.STSSeconds=315360000
      - traefik.http.middlewares.n8n.headers.browserXSSFilter=true
      - traefik.http.middlewares.n8n.headers.contentTypeNosniff=true
      - traefik.http.middlewares.n8n.headers.forceSTSHeader=true
      - traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}
      - traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true
      - traefik.http.middlewares.n8n.headers.STSPreload=true
    environment:
      - N8N_EMAIL_MODE=smtp
      - N8N_SMTP_HOST=smtp.gmail.com
      - [email protected]
      - N8N_SMTP_PASS=my-gmail-password
      - [email protected]
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
    volumes:
      - ${DATA_FOLDER}/.n8n:/home/node/.n8n

I assume this is what you are after and not how to set up the SMTP credentials in n8n to send an email as part of a workflow.

Basically, i have not tried because I am not so tech-savvy so I assume that I need to add the below lines in docker-compose.yml and try to use and see how its work,

Do we need to add SMTP codes in .ENV also

environment:
- N8N_EMAIL_MODE=smtp
- N8N_SMTP_HOST=smtp.gmail.com
- [email protected]
- N8N_SMTP_PASS=my-gmail-password
- [email protected]
- N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
- N8N_PORT=5678
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
- GENERIC_TIMEZONE=${GENERIC_TIMEZONE}

Hey @chandan988,

Nothing in .env but if you wanted to you could move the credentials into the .env file and follow the same pattern as the subdomain to use it from there.


i have done changes in my environment as per instructions given but still getting this error

image
any one can help how to resolve this issue


I tested email from Postfix on Ubuntu its sends the test email successfully with the same credentials but in n8n We are facing issue configure

Anyone who has done setting please let me know what to do

Hey @chandan988,

Did you restart the container after making the change?

i restarted the whole server :grinning: but still not able to remove that notification is their any solution we can create users without sending email to them, I means we can create ID & password in dashboard only

If you check the docker log for n8n does it show any errors?

I will give the same file a run in a bit and see what happens, which mail provider are you using as well?

mail provider : mailersend
Postfix is already installed and test mail is working fine

Hey @chandan988,

I have just set up a new instance here using Mailersend and there are a couple of other options that need to be set as it doesn’t use port 465 it used 587 and StartTLS to get this running I have used…

N8N_EMAIL_MODE=smtp
N8N_SMTP_HOST=smtp.mailersend.net
N8N_SMTP_PORT=587
N8N_SMTP_SSL=false
[email protected]
N8N_SMTP_PASS=pass-from-mailersend
[email protected]

Once you have these set make sure you recreate the container so the new settings are picked up, So I would do something like the below which should sort it out.

docker-compose down
docker-compose up -d --build
2 Likes

Really thanks a lot @Jon now its working

1 Like

is their any environment to set sender name as well because right now email is coming from same email id as sender name

  1. any option to change the email body, Subject
  2. Any API based user invite or disable access to n8n application via API are these things available

Hey @chandan988,

N8N_SMTP_SENDER should allow you to set the sender but it is worth noting that not all mail providers allow a different sender (Microsoft 365 is one of the services that doesn’t allow it), You can change the invite email by setting N8N_UM_EMAIL_TEMPLATES_INVITE to the path of a file that contains the HTML to use and for the password reset email you can do the same thing with N8N_UM_EMAIL_TEMPLATES_PWRESET. The subject can’t be changed but I can add it to our internal feature tracker :slight_smile:

As you are using Docker you will need to make sure the container can access the templates you use so it could be a case of making a folder on the host called email-templates under the local-files folder if you have that configured correctly.

Then you can set the environment options to /files/email-templates/invite.html before you do that though I would recommend checking that the container can access that path, The quickest option would be to add an Execute Command node and tell it to run touch /files/file.txt if you don’t get an error you should be good to go and on your host system under /local-files you should see a file.txt with no content.

There is currently no API to invite or delete users but we are working on a public API and I suspect that is a feature we would be looking to add to it at some point.

Config Options: User management | Docs
Default Templates: n8n/packages/cli/src/UserManagement/email/templates at master · n8n-io/n8n · GitHub

I have the exact same issue and confirmed my config is identical to what is here, and still, n8n refuses to “see” the SMTP configuration and I cannot invite users. There are no logs in docker for n8n container after “Editor is now accessible via: https://data.trove.agency:5678/” – I also did a docker exec -it <n8n_container> /bin/sh and verified the env vars are there and are correct.

Hey @phpguru,

Welcome to the community :raised_hands:

Can you share the config you are using?

I am using the clone of n8n-digital-ocean

I’ve added all the environment variables and double checked them. They’re available inside the n8n container, so I don’t know what is missing.

Hey @phpguru,

Can you share the config you are using? I have set up a Digital Ocean droplet this morning with the template after adding the SMTP options and it appears to be working. The only thing I can think of at the moment is there is a typo with an environment option or maybe anonymous auth is being used.