Closed Antoninnnn closed 4 months ago
Hi, Can you share your json configuration file?
Hi, Can you share your json configuration file?
This is the way i define in the bootstrap.js
const { getConfig } = require('@evershop/evershop/src/lib/util/getConfig');
const { addProcessor } = require('@evershop/evershop/src/lib/util/registry');
const config = require('config');
module.exports = () => {
const nodemailerConfig = {
"from": "Customer Service <sixdy2024@qq.com>",
"events": {
"order_placed": {
"subject": "Order Confirmation",
"enabled": true,
"templatePath": undefined
},
"reset_password": {
"subject": "Reset Password",
"enabled": true,
"templatePath": undefined
},
"customer_registered": {
"subject": "Welcome",
"enabled": true,
"templatePath": undefined
}
}
};
config.util.setModuleDefaults('nodemailer', nodemailerConfig);
// Add a processor to proceed the email data before sending
addProcessor('nodemailer_order_confirmation_email_data', (order) => {
// Convert the order.created_at to a human readable date
const locale = getConfig('shop.language', 'en');
const options = { year: 'numeric', month: 'long', day: 'numeric' };
// eslint-disable-next-line no-param-reassign
order.created_at = new Date(order.created_at).toLocaleDateString(
locale,
options
);
// Add the order total text including the currency
// eslint-disable-next-line no-param-reassign
order.grand_total_text = Number(order.grand_total).toLocaleString(locale, {
style: 'currency',
currency: order.currency
});
return order;
});
};
And i did not introduce the html template yet.
OOOOOOOH no!!! I made a mistake in the const from = getConfig('nodemailor.from', '');
It should be const from = getConfig('nodemailer.from', '');
Thank you so much
By the way, I am also curious about the trigger mechanism of these functions, could you explain more?
What function @Antoninnnn ?
The functions sendOrderConfirmationEmail
,sendOrderConfirmationEmail
.
I notice it in your documentation events and subscribers .
Describe the bug No action was performed when i created a user, place an order or reset password.
To Reproduce I created an extension similarly like the resend packages you provided. I have tested that my SMTP server worked well. I am not sure how the
sendOrderConfirmationEmail
,sendOrderConfirmationEmail
or the reset password function was triggered. Could you give some clues about the problem?Here is how i write the
sendWelcomeEmail.js
:Background (please complete the following information):
Additional context Add any other context about the problem here.