Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
camino
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
pnm-public
camino
Commits
81a77fab
Commit
81a77fab
authored
6 years ago
by
Francois Romain
Browse files
Options
Downloads
Patches
Plain Diff
feat: envoie les messages avec mailjet
parent
8448c218
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.env-example
+3
-3
3 additions, 3 deletions
.env-example
tools/mailer/index.js
+20
-18
20 additions, 18 deletions
tools/mailer/index.js
with
23 additions
and
21 deletions
.env-example
+
3
−
3
View file @
81a77fab
...
...
@@ -17,9 +17,9 @@ PGUSER=pg-user
PGPASSWORD=''
# email
EMAIL_
SERVICE=serviceName
EMAIL_
USER=email@site.com
EMAIL_
PASSWORD=pass
EMAIL_
API_KEY=key
EMAIL_
API_PASSWORD=password
EMAIL_
SMTP_SERVER=server
# connexion a l'API google drive pour importer les données
GOOGLE_PROJECT_ID="example"
...
...
This diff is collapsed.
Click to expand it.
tools/mailer/index.js
+
20
−
18
View file @
81a77fab
const
nodemailer
=
require
(
'
nodemailer
'
)
const
smtpTransport
=
require
(
'
nodemailer-smtp-transport
'
)
//
const smtpTransport = require('nodemailer-smtp-transport')
const
smtpTransportConfig
=
{
service
:
process
.
env
.
EMAIL_SERVICE
,
auth
:
{
user
:
process
.
env
.
EMAIL_USER
,
pass
:
process
.
env
.
EMAIL_PASSWORD
}
}
// const smtpTransportConfig = smtpTransport({
// service: process.env.EMAIL_SERVICE,
// auth: {
// user: process.env.EMAIL_USER,
// pass: process.env.EMAIL_PASSWORD
// }
// })
const
smtpTransportConfig
=
`smtps://
${
process
.
env
.
EMAIL_API_KEY
}
:
${
process
.
env
.
EMAIL_API_PASSWORD
}
@
${
process
.
env
.
EMAIL_SMTP_SERVER
}
`
const
from
=
process
.
env
.
EMAIL_USER
const
transport
=
nodemailer
.
createTransport
(
smtpTransport
(
smtpTransportConfig
)
)
const
transport
=
nodemailer
.
createTransport
(
smtpTransportConfig
)
const
mailer
=
(
to
,
subject
,
text
,
html
)
=>
{
const
mailer
=
async
(
to
,
subject
,
text
,
html
)
=>
{
const
mail
=
{
from
,
to
,
subject
,
text
,
html
}
transport
.
sendMail
(
mail
,
(
error
,
res
)
=>
{
if
(
error
)
{
console
.
log
(
error
)
}
else
{
console
.
log
(
`Message sent:
${
res
.
response
}
`
)
}
try
{
const
res
=
await
transport
.
sendMail
(
mail
)
console
.
log
(
`Message sent:
${
res
.
response
}
`
)
transport
.
close
()
})
}
catch
(
e
)
{
console
.
log
(
e
)
}
}
module
.
exports
=
mailer
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment