0

I configured nuxt-mail in the nuxt.config.js file like (My EMAIL_HOST env var is the domain of my mail server):

mail: {
    message: {
        from: process.env.EMAIL_USERNAME,
        to: process.env.EMAIL_RECIPIENT,
    },
    smtp: {
        host: process.env.EMAIL_HOST,
        port: parseInt(process.env.EMAIL_PORT, 10),
        secure: true,
        auth: {
            user: process.env.EMAIL_USERNAME,
            pass: process.env.NUXT_EMAIL_PASSWORD,
        },
    },
},

And I send it in my form like this:

const mail = useMail()

function sendMail() {
    const emailContent = `
        <div style="font-family: Arial, sans-serif; line-height: 1.6;">...</div>
    `;
    mail.send({
        from: `${firstname.value} ${lastname.value}`,
        subject: subject.value,
        html: emailContent,
        replyTo: email.value,
    });
}

This works fine in development mode and I receive all mails correctly. However after building, I get the following errors in my console:

http://localhost:3000/mail/send 500 (connect ECONNREFUSED 127.0.0.1:465)

Uncaught (in promise) Error: connect ECONNREFUSED 127.0.0.1:465 at Object.send

The production server is a VPS using PM2 as the process manager, but the build already does not work locally, so I don't think that's the issue.

Does anyone have an idea how to solve this?

Thanks a lot.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.