Open loganess opened 1 month ago
I assume you're entering your actual smtp credentials and not the example credentials given above? Because those of course will not work. Is there an error shown in the console where Vendure is running?
Correct. I changed the smtp credential in my post. There is no error shown in the console, and email is not set in dev mode.
Also tried to enable debug log for SMTP, but nothing shows up from console. Email for new account and password recovery request work fine.
Any idea how to make it works? or do i miss anything? Thank you.
If I were troubleshooting, I would first make sure the template exists under 'vendure/static/email/templates/order-confirmation'. Then I would copy the template somewhere else and use the default template to make sure it is not a template compilation issue. If still no luck, I would change the config for the email plugin to use the dev mailbox to see if it is maybe an smtp issue.
devMode: true,
outputPath: path.join(__dirname, '../static/email/test-emails'),
route: 'mailbox',
If still no luck, I would make a new folder with a brand new Vendure install and then make changes one by one to try troubleshooting the issue that way.
If you changed the header and/or footer partial, also copy those somewhere else and use the default. Those can cause compilation issues, too. Invalid mjml or hbs will cause the templates to not compile, so the message will not be sent.
Thanks @pevey I set to use devMode, and still unable to receive order confirmation email, except generating manually Also restored all email template includes header and footer.
Try starting with a fresh project and link to the repo with a reproduction of the issue. There's nothing much the vendure team can do without being able to reproduce the error. Starting from a fresh project and changing only the email settings might help you pinpoint the issue.
Still not able to getting the console log for order confirmation email. Testing on Ubuntu 24.04, Node 20.17.0 I attached vendure configure file:
import {
dummyPaymentHandler,
DefaultJobQueuePlugin,
DefaultSearchPlugin,
VendureConfig,
} from '@vendure/core';
import { defaultEmailHandlers, EmailPlugin, FileBasedTemplateLoader } from '@vendure/email-plugin';
import { orderConfirmationHandler } from '@vendure/email-plugin';
import { StripePlugin } from '@vendure/payments-plugin/package/stripe';
import { AssetServerPlugin } from '@vendure/asset-server-plugin';
import { AdminUiPlugin } from '@vendure/admin-ui-plugin';
import 'dotenv/config';
import path from 'path';
const IS_DEV = process.env.APP_ENV === 'dev';
const serverPort = +process.env.PORT || 3000;
export const config: VendureConfig = {
apiOptions: {
port: serverPort,
adminApiPath: 'admin-api',
shopApiPath: 'shop-api',
// The following options are useful in development mode,
// but are best turned off for production for security
// reasons.
...(IS_DEV ? {
adminApiPlayground: {
settings: { 'request.credentials': 'include' },
},
adminApiDebug: true,
shopApiPlayground: {
settings: { 'request.credentials': 'include' },
},
shopApiDebug: true,
} : {}),
},
authOptions: {
tokenMethod: ['bearer', 'cookie'],
superadminCredentials: {
identifier: process.env.SUPERADMIN_USERNAME,
password: process.env.SUPERADMIN_PASSWORD,
},
cookieOptions: {
secret: process.env.COOKIE_SECRET,
},
},
dbConnectionOptions: {
type: 'postgres',
// See the README.md "Migrations" section for an explanation of
// the `synchronize` and `migrations` options.
synchronize: true,
migrations: [path.join(__dirname, './migrations/*.+(js|ts)')],
logging: false,
database: process.env.DB_NAME,
schema: process.env.DB_SCHEMA,
host: process.env.DB_HOST,
port: +process.env.DB_PORT,
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
},
paymentOptions: {
paymentMethodHandlers: [dummyPaymentHandler],
},
// When adding or altering custom field definitions, the database will
// need to be updated. See the "Migrations" section in README.md.
customFields: {},
plugins: [
AssetServerPlugin.init({
route: 'assets',
assetUploadDir: path.join(__dirname, '../static/assets'),
// For local dev, the correct value for assetUrlPrefix should
// be guessed correctly, but for production it will usually need
// to be set manually to match your production url.
//assetUrlPrefix: IS_DEV ? undefined : 'https://www.my-shop.com/assets/',
assetUrlPrefix: 'https://api-shop.test-domain.com/assets/',
}),
DefaultJobQueuePlugin.init({ useDatabaseForBuffer: true }),
DefaultSearchPlugin.init({ bufferUpdates: false, indexStockStatus: true }),
EmailPlugin.init({
handlers: [
...defaultEmailHandlers,
orderConfirmationHandler.setOptionalAddressFields(event => {
return {
cc: 'order@test-domain.com',
bcc: 'jack@test-domain.com'
}
}) as any,
],
//templatePath: path.join(__dirname, '../static/email/templates'),
templatePath: path.join(__dirname, '../static/email/templates'),
transport: {
type: 'smtp',
host: 'imap.test-domain.com',
port: 587,
auth: {
user: 'no-reply@test-domain.com',
pass: 'testpassword',
},
},
globalTemplateVars: {
// The following variables will change depending on your storefront implementation
fromAddress: '"TEST | shop" <shop@test-domain.com>',
verifyEmailAddressUrl: 'https://shop.test-domain.com/verify',
passwordResetUrl: 'https://shop.test-domain.com/password-reset',
changeEmailAddressUrl: 'https://shop.test-domain.com/verify-email-address-change'
},
}),
StripePlugin.init({
// This prevents different customers from using the same PaymentIntent
storeCustomersInStripe: true,
}),
AdminUiPlugin.init({
route: 'admin',
port: serverPort + 2,
adminUiConfig: {
apiPort: serverPort,
},
}),
],
};
Console log shows:
shop@vendure3:~/shop$ pwd
/home/shop/shop
[server] > ts-node ./src/index.ts
[server]
[worker] info 10/10/24, 2:06 PM - [Vendure Worker] Bootstrapping Vendure Worker (pid: 127630)...
[server] info 10/10/24, 2:07 PM - [Vendure Server] Bootstrapping Vendure Server (pid: 127632)...
[worker] info 10/10/24, 2:07 PM - [Vendure Worker] Vendure Worker is ready
[worker] info 10/10/24, 2:07 PM - [JobQueue] Starting queue: apply-collection-filters
[worker] info 10/10/24, 2:07 PM - [JobQueue] Starting queue: update-search-index
[worker] info 10/10/24, 2:07 PM - [JobQueue] Starting queue: send-email
[server] info 10/10/24, 2:07 PM - [AdminUiPlugin] Creating admin ui middleware (prod mode)
[server] info 10/10/24, 2:07 PM - [AssetServerPlugin] Creating asset server middleware
[server] info 10/10/24, 2:07 PM - [RoutesResolver] HealthController {/health}:
[server] info 10/10/24, 2:07 PM - [RouterExplorer] Mapped {/health, GET} route
[server] info 10/10/24, 2:07 PM - [RoutesResolver] StripeController {/payments}:
[server] info 10/10/24, 2:07 PM - [RouterExplorer] Mapped {/payments/stripe, POST} route
[server] info 10/10/24, 2:07 PM - [GraphQLModule] Mapped {/shop-api, POST} route
[server] info 10/10/24, 2:07 PM - [GraphQLModule] Mapped {/admin-api, POST} route
[server] info 10/10/24, 2:07 PM - [NestApplication] Nest application successfully started
[server] info 10/10/24, 2:07 PM - [Vendure Server] ================================================
[server] info 10/10/24, 2:07 PM - [Vendure Server] Vendure server (v3.0.4) now running on port 3000
[server] info 10/10/24, 2:07 PM - [Vendure Server] ------------------------------------------------
[server] info 10/10/24, 2:07 PM - [Vendure Server] Shop API: http://localhost:3000/shop-api
[server] info 10/10/24, 2:07 PM - [Vendure Server] Admin API: http://localhost:3000/admin-api
[server] info 10/10/24, 2:07 PM - [Vendure Server] Asset server: http://localhost:3000/assets
[server] info 10/10/24, 2:07 PM - [Vendure Server] Admin UI: http://localhost:3000/admin
[server] info 10/10/24, 2:07 PM - [Vendure Server] ================================================
[server] ValidationError: The 'X-Forwarded-For' header is set but the Express 'trust proxy' setting is false (default). This could indicate a misconfiguration which would prevent express-rate-limit from accurately identifying users. See https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/ for more information.
[server] at Object.xForwardedForHeader (/home/shop/shop/node_modules/express-rate-limit/dist/index.cjs:167:13)
[server] at Object.wrappedValidations.<computed> [as xForwardedForHeader] (/home/shop/shop/node_modules/express-rate-limit/dist/index.cjs:362:22)
[server] at Object.keyGenerator (/home/shop/shop/node_modules/express-rate-limit/dist/index.cjs:617:20)
[server] at /home/shop/shop/node_modules/express-rate-limit/dist/index.cjs:670:32
[server] at processTicksAndRejections (node:internal/process/task_queues:95:5)
[server] at async /home/shop/shop/node_modules/express-rate-limit/dist/index.cjs:650:5 {
[server] code: 'ERR_ERL_UNEXPECTED_X_FORWARDED_FOR',
[server] help: 'https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/'
[server] }
Describe the bug Vendure doesn't send order confirmation email.
My setting for email plugin as below:
Environment (please complete the following information):