#how do I debug existing plugins?

45 messages · Page 1 of 1 (latest)

patent wave
#

I'm working on a local dockerised setup and I have medusa backend running and workon ports 7001, 8000 etc. I also have mailhog, redis and postgres images. All is good. But the emails are not going out.

I created a node image for node like this

FROM node:18-buster-slim

# Install system requirements
# Use non-interactive frontend for debconf
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

# Install system requirements
RUN apt-get update && \
    apt-get install -y --no-install-recommends git python wget && \
    rm -rf /var/lib/apt/lists/*

RUN wget https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 --no-check-certificate
RUN chmod +x mhsendmail_linux_amd64
RUN mv mhsendmail_linux_amd64 /usr/local/bin/mhsendmail
# Set the default directory where CMD will execute
WORKDIR /app

# Set the default command to execute when creating a new container
COPY scripts/node-dev-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh", "--"]
CMD bash

And I have smtp plugin set up like this:

  {
    resolve: `medusa-plugin-smtp`,
    transport: {
        sendmail: true,
        path: "/usr/local/bin/mhsendmail",
        newline: "unix",
    },
    options:{
      fromEmail: "noreply@medusajs.com",
      host: "mailhog",
      port: 1025,
      secureConnection: false,
      auth: {
        user: "",
        pass: "",
      },
    }
  },

I see medusa-backend-1 | info: Processing user.password_reset which has 1 subscribers in my shell, but what i Do not see is email going out. **How can I debug this? ** I tried with default sendmail but that worked just as little as with mhsendmail. Help please.

formal phoenix
#

this config is not set correctly, make sure you update with your own smtp data

patent wave
#

Why would you think it's not correctly set up and what do you think the error is? "mailhog" is the name of the mailhog container and port 1025 is open on it. Where's there error? Can you point it out for me?

formal phoenix
#

😄

#

no user no password

patent wave
#

yup. There's no username nad password

formal phoenix
#

fromemail is medusa

formal phoenix
patent wave
#

does it matter? it's for my local testing. The mailhog service literally runs in the container.

formal phoenix
#

you are probably listed as openrelay and all emails are blocked

#

if is local check the logs of the smtp

patent wave
#

As for the general setup - I've used mailhog exactly like this in other projects (they are python based though, so there may be some differences)

formal phoenix
#

also in the medusa host you have /usr/local/bin/mhsendmail

patent wave
formal phoenix
#

ok, have you tested it? from command line?

patent wave
#

Nope. Not yet. I'll do that

#

Worked just fine from inside the container

formal phoenix
#

this is from medusa container right?

patent wave
#

yup

formal phoenix
#

check the logs of mailhog

patent wave
#

Yeah, I don't think that's the stuff to test here. I mean, I've used mailhog extensively and it's such a simple and straighforward thing. Since the shell command worked just fine I'm much more interested in how I can debug the JS portion now. How can I check which way the JS executes the code now?

formal phoenix
#

you do not have emailTemplatePath and templateMap

#

also not sure if you need an auth section if no auth required

patent wave
#

Yeah, not sure either how the plugin is supposed to be used. I kinda figured the project includes some default templates? Does it? Same with templateMap, I guess. Is there some kind of default email templates that MedusaJS has?

formal phoenix
#
// this is the path where your email templates are stored
    emailTemplatePath: "data/emailTemplates",
#

just check here the config, create a test template

#

create the map

#

and give a try

patent wave
#

yup yup. I figured it's a default setting to someplace where the medusajs default email templates are. Are there default medusa js email templates?

#

and as for mapping - where is the documentation what the mapping should look like? What are the expected keys in the mapping?

formal phoenix
patent wave
formal phoenix
#

there is a search on the top right corner and it is working

patent wave
formal phoenix
patent wave
#

so I know what kind of fields are in the data so I know what to put into the template. But you're probably right. The smth plugin fails because templates are not there. I'll try to create some dummy ones.

#

Thank you for your time @formal phoenix

#

Yeah, Well.. no luck. I created the template: and updated the config. The email template is there, but I see no email... How to debug futher?

formal phoenix
#

Remove the auth part

#

Clone the plugin locally add some logs and install from local

patent wave
formal phoenix
#

npm install /path