Commit d2125650 by jaymehta

.

1 parent 362c60e6
......@@ -20,6 +20,7 @@
"@strapi/utils": "^4.24.3",
"aws-sdk": "^2.1644.0",
"csv-parse": "^5.5.5",
"mailgen": "^2.0.28",
"mysql": "^2.18.1",
"pg": "^8.8.0",
"strapi-plugin-ckeditor5": "^2.1.1-rc.1"
......

How to get SMTP username & password:
(https://docs.aws.amazon.com/ses/latest/dg/smtp-credentials.html)
SMTP server: email-smtp.us-east-1.amazonaws.com
(https://docs.aws.amazon.com/general/latest/gr/ses.html)
SMTP port: 587 (STARTTLS) or you can use SSL/TLS on port 465
(https://docs.aws.amazon.com/ses/latest/dg/smtp-connect.html)
ses-smtp-user.20240626-110226
SMTP port: 587
SMTP server: email-smtp.us-east-1.amazonaws.com
SMTP username: AKIAW3MEAX6X7OTM7XJO
SMTP password: BEraiPaP1Kqcnv74V3KX+hiuHnMgAcrOALc6AXdWjN43
IAM user name,SMTP user name,SMTP password
ses-smtp-user.20240626-110226,AKIAW3MEAX6X7OTM7XJO,BEraiPaP1Kqcnv74V3KX+hiuHnMgAcrOALc6AXdWjN43
......@@ -186,14 +186,18 @@
]
},
"termsConditions": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": false
]
},
"cancellationPolicyText": {
"type": "text"
}
}
}
......@@ -2,7 +2,8 @@
const { getService } = require("@strapi/plugin-users-permissions/server/utils");
const fs = require("fs");
var Mailgen = require("mailgen");
const nodemailer = require("nodemailer");
/**
* vendor controller
*/
......@@ -156,6 +157,73 @@ module.exports = createCoreController("api::vendor.vendor", () => ({
}
},
async sendMail(ctx) {
// var transport = nodemailer.createTransport({
// host: "sandbox.smtp.mailtrap.io",
// port: 2525,
// auth: {
// user: "7779108f5d4590",
// pass: "cbcba36dcf85ba"
// }
// });
var mailGenerator = new Mailgen({
theme: "default",
product: {
// Appears in header & footer of e-mails
name: "Zango",
link: "https://mailgen.js/",
// Optional product logo
logo: 'https://zangoaws.s3.amazonaws.com/main_logo_e32eeef63e.svg?updated_at=2024-06-26T11:05:28.634Z'
},
});
var email = {
body: {
name: "Jay Mehta",
intro: "Welcome to Zango! We're very excited to have you on board.",
action: {
instructions: "To get started with signup, please confirm the OTP:",
button: {
color: "red", // Optional action button color
text: "8291",
// link: "https://mailgen.js/confirm?s=d9729feb74992cc3482b350163a1a010",
},
},
outro:
"Need help, or have questions? Please mail on graheja@zangoexperiences.com.",
},
};
// Generate an HTML email with the provided contents
var emailBody = mailGenerator.generate(email);
console.log("email", emailBody);
var transport = nodemailer.createTransport({
host: "sandbox.smtp.mailtrap.io",
port: 2525,
auth: {
user: "7779108f5d4590",
pass: "cbcba36dcf85ba",
},
});
async function main() {
// send mail with defined transport object
const info = await transport.sendMail({
from: "Team Zango <graheja@zangoexperiences.com>", // sender address
to: "jay@logicloop.io", // list of receivers
subject: "OTP Verification", // Subject line
// text: "Hello world?", // plain text body
html: emailBody, // html body
});
console.log("Message sent: %s", info.messageId);
// Message sent: <d786aa62-4e0a-070a-47ed-0b0666549519@ethereal.email>
}
main().catch(console.error);
},
async removedirectory(ctx) {
// directory path
const dir = `${__dirname}/../../../../../zango-frontend`;
......
......@@ -24,7 +24,16 @@ const routes = {
// some configuration...
}
},
{
method: "POST",
path: "/vendor/send-mail",
handler: "api::vendor.vendor.sendMail",
config: {
// some configuration...
}
},
],
};
......
"use strict";
var Mailgen = require("mailgen");
/**
* vendor service
*/
......@@ -261,5 +262,42 @@ module.exports = createCoreService(
}
};
},
async sendMail() {
// Configure mailgen by setting a theme and your product info
var mailGenerator = new Mailgen({
theme: "default",
product: {
// Appears in header & footer of e-mails
name: "Mailgen",
link: "https://mailgen.js/",
// Optional product logo
// logo: 'https://mailgen.js/img/logo.png'
},
});
var email = {
body: {
name: "John Appleseed",
intro: "Welcome to Mailgen! We're very excited to have you on board.",
action: {
instructions: "To get started with Mailgen, please click here:",
button: {
color: "#22BC66", // Optional action button color
text: "Confirm your account",
link: "https://mailgen.js/confirm?s=d9729feb74992cc3482b350163a1a010",
},
},
outro:
"Need help, or have questions? Just reply to this email, we'd love to help.",
},
};
// Generate an HTML email with the provided contents
var emailBody = mailGenerator.generate(email);
console.log("email", emailBody);
// Generate the plaintext version of the e-mail (for clients that do not support HTML)
var emailText = mailGenerator.generatePlaintext(email);
},
})
);
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!