2 emails being sent to 2 different email addresses for invoice sent confirmation

I recently deployed a v5 docker stack and migrated my v4 over. During the initial deployment of the v5 docker stack I set the initial user in the .yml

IN_USER_EMAIL: [email protected]
IN_PASSWORD: randompassword

After migration, setting up the user I intended to use:

[email protected]

I then commented out this initial user, but for some reason when sending invoices, and only invoices (quotes not affected) the sent confirmation email is sent to both [email protected] & [email protected].

Is there some other location in settings where emails are set for invoices sent confirmation emails? I can not find where [email protected] is set so I can remove this email from being sent invoice confirmation emails.

Hi,

Is it possible you have more than user in the company?

Not that I can see

Under User Details there is just one user: [email protected]

Under User Management there is nothing.

@david do you have any ideas?

1 Like

Is it possible you have one of these pointing to the old address/user?

  • Settings>Email Settings>BCC Email
  • When emailing an invoice, the ‘CC Email’ field
  • Settings>User Details>Notifications>Invoice Created (take a look at both users setting here)
  • Settings>Email Settings>BCC Email = BLANK
  • When emailing an invoice, the ‘CC Email’ field = BLANK
  • Settings>User Details>Notifications>Invoice Created = NONE

Could that email be cached somewhere? I have updated and restarted the containers but I haven’t deleted them or the images then recreated.

Here is my docker-compose.yml

version: '3.7'

services:

  in-server:
    image: nginx
    restart: unless-stopped
    volumes:
      # Wichtig! Hier die in-vhost.conf einbinden.
      # Important! Include in-vhost.conf here.
      - /portainer/Files/AppData/Config/Invoice-Ninja/config/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro
      # Hier das Public-Verzeichnis von invoice ninja einbinden.
      # Include the public folder for invoice ninja here.
      - /portainer/Files/AppData/Config/Invoice-Ninja/public:/var/www/app/public:ro
    depends_on:
      - in-app
    # Run webserver nginx on port 8080
    ports:
      - "8081:80"
    healthcheck:
      test: curl -f http://localhost:80/ || exit 1
    #networks:
    #  default:
    #    ipv4_address: 172.17.0.4

  in-db:
    image: mariadb:10.4
    restart: unless-stopped
    volumes:
      - /portainer/Files/AppData/Config/Invoice-Ninja/data:/var/lib/mysql:rw,delegated
    environment:
      # Passwort anpassen!! Änderungen müssen unten auch angepasst werden.
      # Adjust passwords!! Don't forget to adjust them further down accordingly.
      MARIADB_PASSWORD: randompw
      MARIADB_ROOT_PASSWORD: randompw
      MARIADB_DATABASE: ninja
      MARIADB_USER: ninja
      PUID: 0
      PGID: 0
    #networks:
    #  default:
    #    ipv4_address: 172.17.0.6

  in-cache:
    image: redis
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "redis-cli ping || exit 1"]
    #networks:
    #  default:
    #    ipv4_address: 172.17.0.7
    
  in-app:
    image: invoiceninja/invoiceninja:5
    restart: unless-stopped
    volumes:
      - /portainer/Files/AppData/Config/Invoice-Ninja/public:/var/www/app/public:rw,delegated
      - /portainer/Files/AppData/Config/Invoice-Ninja/storage:/var/www/app/storage:rw,delegated
    depends_on:
      in-db:
        condition: service_started
      in-cache:
        condition: service_healthy
    environment:
      APP_NAME: "Invoice Ninja"
      APP_ENV: production
      # Hier den erstellten Key einfĂźgen.
      # Insert the generated key here.
      # docker run --rm -it invoiceninja/invoiceninja php artisan key:generate --show
      APP_KEY: base64:somerandomlongstringofnumbersandletters
      APP_DEBUG: 0
      # URL und Port von nginx
      APP_URL: "https://invoice.mydomain.com"
      IS_DOCKER: true
      PHANTOMJS_PDF_GENERATION: 0
      PDF_GENERATOR: snappdf
      TRUSTED_PROXIES: '*'
      MULTI_DB_ENABLED: 0
      DB_HOST: in-db
      DB_DATABASE: ninja
      DB_USERNAME: ninja
      DB_PASSWORD: randompw
      DB_PORT: 3306
      PUID: 0
      PGID: 0


      # Cache settings
      CACHE_DRIVER: redis
      SESSION_DRIVER: redis
      REDIS_HOST: in-cache

      # SMTP Einstellungen des E-Mail Kontos
      # SMTP Settings
      # MAIL_MAILER: smtp
      # MAIL_HOST: smtp.gmail.com
      # MAIL_PORT: 587
      # MAIL_USERNAME: [email protected]
      # MAIL_PASSWORD: randompw
      # MAIL_ENCRYPTION: TLS
      # MAIL_FROM_ADDRESS: [email protected]
      # MAIL_FROM_NAME: "Accounting"

      REQUIRE_HTTPS: 0
      NINJA_ENVIRONMENT: selfhost

      # Login fĂźr die erste Anmeldung.
      # Data for initial login.
      # IN_USER_EMAIL: [email protected]
      # IN_PASSWORD: randompw

I would run a query in the database for the old email. That would point to where it’s stored. Query all tables

1 Like

is it possible these are being forwarded outside of the app?

This was my exact thought as well.

When I migrated from a bare metal install into a VM, I had this similar thing happen to me.

also, you need to run php artisan optimize after changing env file.

According to the reply from @hillel in the topic below, my understanding was that is not needed any longer.

That being said, on a problem I am trying to solve, changes to my .env would not take effect until after running php artisan optimize.

This was the issue. There was 2 users for each email with the same account_id

Thanks everyone!

I ran this prior to the db edit. Now something is wrong with pfd generation. When creating a invoice there will be a error “Something went wrong” and not pd if generated. All of my pervious invoices pdfs have a basic design. Not the playful design I have in settings.

I define my environment variables in the .yml but it seems is it not being used now?

**environment:
      APP_NAME: "Invoice Ninja"
      APP_ENV: production
      # Hier den erstellten Key einfĂźgen.
      # Insert the generated key here.
      # docker run --rm -it invoiceninja/invoiceninja php artisan key:generate --show
      APP_KEY: base64:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
      APP_DEBUG: 0
      # URL und Port von nginx
      APP_URL: "https://invoice.mydomain.com"
      IS_DOCKER: true
      PHANTOMJS_PDF_GENERATION: 0
      PDF_GENERATOR: snappdf
      TRUSTED_PROXIES: '*'
      MULTI_DB_ENABLED: 0
      DB_HOST: in-db
      DB_DATABASE: ninja
      DB_USERNAME: ninja
      DB_PASSWORD: randompw
      DB_PORT: 3306
      PUID: 0
      PGID: 0**

Would running php artisan optimize cause issues with pdf generation? If not would deleting that rouge user cause this?

Side note: Invoice Design setting flipping through the themes pdf generate and change themes as expected. the issues is with new and existing pdf’s.

Update: Changing the design theme to a different theme saving then going back to the playfull theme and selecting “update all records” fixes all already generated invoices. Just having issues with new invoice pdf generation with the error “Something went wrong”

I’m glad to hear you have fixed part of the problem.

I’m sorry, I have a bad relationship with Docker and am not able to provide an assistance related to that configuration.

Can you share your .env file with the secrets and passwords removed? That information could help.

Well im not sure there is one inside the container since I defined them in the .yml. I looked in the container but I couldn’t find it. I know if it is in there it is hidden. The image is the official image: image: invoiceninja/invoiceninja:5 but my deployment stack is different from the official documentation.

This was working prior to running php artisan optimize and the database edit. I thinking it is because the deleted user was "userId":1 I then changed my user from "userId":2 to "userId":1

laravel.log is showing this error

production.ERROR: Call to a member function present() on null {"userId":1,"exception":"[object] (Error(code: 0): Call to a member function present() on null at /var/www/app/app/Utils/HtmlEngine.php:405)

You’ll need a reply from @hillel or @david to help with the laravel error.

According to the official InvoiceNinja Docker installation instructions here it should be in the .env file. However, if you have an unofficial installation, I don’t know how much help will be offered. I’m not saying it won’t, I just don’t know, because I’m only another user like you. On some other open source software I use, if one does not install using the official methods, they don’t offer free support. Not sure how they feel here.

I also don’t know if php artisan optimize should be used on the Docker install without an .env file. Nowhere (that I could find) in the Docker installation documents does it say to use php artisan optimize.

Depending on how you did your Docker installation, the .env file would be in your default installation directory. Maybe dockerfiles or invoiceninja? If it is /invoiceninja (assuming it’s Linux based), you could use ls -la /invoiceninja and it will list all of the documents and directories within there and you can see if the .env file exists. You could also use find to search for your .env file.

Ive went over that documentation a many times, but had troubles with how im deploying my containers. As I said it was working prior to the edits i made to fix the hidden user email.

I will probably move the environment variables out of the .yml and into a .env file this weekend.

Thanks again for the help

If you are on docker you won’t be using php artisan optimize, since the web server running php is a container. Instead, after you change the environment variables file used by docker you will need to restart the Invoice Ninja linux container so it gets picked up (docker-compose restart)

I have restarted that container several times. The only issue is when making a new invoice the “live” creation docent generate and a error at the top just says “something went wrong”. I can save the invoice, back out then view it and generates fine.

I resolved this. Reverted that userid back to 2 and everything is fine.