Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jay Mehta
/
zango-strapi
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit d2125650
authored
2024-06-26 20:25:43 +0530
by
jaymehta
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
.
1 parent
362c60e6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
146 additions
and
5 deletions
package-lock.json
package.json
ses-smtp-user-zango-lunaris.20240626-110226_credentials.txt
src/api/experience/content-types/experience/schema.json
src/api/vendor/controllers/vendor.js
src/api/vendor/routes/custom-routes.js
src/api/vendor/services/vendor.js
yarn.lock
package-lock.json
View file @
d212565
This diff is collapsed.
Click to expand it.
package.json
View file @
d212565
...
...
@@ -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"
...
...
ses-smtp-user-zango-lunaris.20240626-110226_credentials.txt
0 → 100644
View file @
d212565
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
src/api/experience/content-types/experience/schema.json
View file @
d212565
...
...
@@ -186,14 +186,18 @@
]
},
"termsConditions"
:
{
"type"
:
"media"
,
"multiple"
:
false
,
"required"
:
false
,
"allowedTypes"
:
[
"images"
,
"files"
,
"videos"
,
"audios"
],
"type"
:
"media"
,
"multiple"
:
false
]
},
"cancellationPolicyText"
:
{
"type"
:
"text"
}
}
}
src/api/vendor/controllers/vendor.js
View file @
d212565
...
...
@@ -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`
;
...
...
src/api/vendor/routes/custom-routes.js
View file @
d212565
...
...
@@ -24,7 +24,16 @@ const routes = {
// some configuration...
}
}
},
{
method
:
"POST"
,
path
:
"/vendor/send-mail"
,
handler
:
"api::vendor.vendor.sendMail"
,
config
:
{
// some configuration...
}
},
],
};
...
...
src/api/vendor/services/vendor.js
View file @
d212565
"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
);
},
})
);
yarn.lock
View file @
d212565
This diff is collapsed.
Click to expand it.
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment