This repository has been archived by the owner on Jan 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(temporary): test send mail to raph via cron
- Loading branch information
1 parent
a19a599
commit c1ca341
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# This is test of the workflow | ||
apiVersion: batch/v1beta1 | ||
kind: CronJob | ||
metadata: | ||
namespace: mon-psy-sante-preprod | ||
name: send-mail-to-raph | ||
labels: | ||
app: mon-psy | ||
spec: | ||
# Every 10 minutes (test purpose) | ||
schedule: "*/10 * * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: mon-psy | ||
image: ghcr.io/socialgouv/mon-psy-sante/app:{{ .Values.global.imageTag }} | ||
envFrom: | ||
- secretRef: | ||
name: app-sealed-secret | ||
- secretRef: | ||
name: pg-user | ||
command: | ||
- yarn | ||
- run | ||
- cron:launch | ||
- sendMailToRaph | ||
restartPolicy: Never | ||
concurrencyPolicy: Forbid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import nodemailer from "nodemailer"; | ||
|
||
import config from "../services/config"; | ||
|
||
const mailTransport = nodemailer.createTransport({ | ||
auth: { | ||
pass: config.mail.auth.pass, | ||
user: config.mail.auth.user, | ||
}, | ||
host: config.mail.host, | ||
ignoreTLS: !config.mail.tls, | ||
port: config.mail.port, | ||
requireTLS: config.mail.tls, | ||
}); | ||
|
||
export function sendMailToRaph() { | ||
const mail = { | ||
from: `MonPsy <${config.supportMail}>`, | ||
html: "<b>bonjour</b> raph", | ||
subject: "salut raph", | ||
text: "bonjour raph", | ||
to: "raph@selego.co", | ||
}; | ||
if (config.mail.enabled) { | ||
return new Promise((resolve, reject) => { | ||
mailTransport.sendMail(mail, (error, info) => { | ||
console.log(error, info); | ||
return error ? reject(error) : resolve(info); | ||
}); | ||
}); | ||
} | ||
console.log("Send email skipped"); | ||
return Promise.resolve(); | ||
} |