aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/emailer.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/emailer.ts')
-rw-r--r--server/lib/emailer.ts23
1 files changed, 21 insertions, 2 deletions
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts
index 3429498e7..9b1c5122f 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -354,13 +354,32 @@ class Emailer {
354 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) 354 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
355 } 355 }
356 356
357 sendMail (to: string[], subject: string, text: string) { 357 addContactFormJob (fromEmail: string, fromName: string, body: string) {
358 const text = 'Hello dear admin,\n\n' +
359 fromName + ' sent you a message' +
360 '\n\n---------------------------------------\n\n' +
361 body +
362 '\n\n---------------------------------------\n\n' +
363 'Cheers,\n' +
364 'PeerTube.'
365
366 const emailPayload: EmailPayload = {
367 from: fromEmail,
368 to: [ CONFIG.ADMIN.EMAIL ],
369 subject: '[PeerTube] Contact form submitted',
370 text
371 }
372
373 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
374 }
375
376 sendMail (to: string[], subject: string, text: string, from?: string) {
358 if (!this.enabled) { 377 if (!this.enabled) {
359 throw new Error('Cannot send mail because SMTP is not configured.') 378 throw new Error('Cannot send mail because SMTP is not configured.')
360 } 379 }
361 380
362 return this.transporter.sendMail({ 381 return this.transporter.sendMail({
363 from: CONFIG.SMTP.FROM_ADDRESS, 382 from: from || CONFIG.SMTP.FROM_ADDRESS,
364 to: to.join(','), 383 to: to.join(','),
365 subject, 384 subject,
366 text 385 text